Vote count:
0
I'm currently trying to create an AddBooking method which adds a given Booking object to the booking dictionary (using the bookingID of the Booking as the key) but i'm really unsure how to do it, I have started it but im not sure what to firstly put in the bracket and then what goes in the method. Any help or advise would be appreciated :)
namespace TheatreShows { public class Show { private string title; private Dictionary bookings;
public string Title
{
get { return title; }
set { title = value; }
}
public Show(string title)
{
this.title = title;
this.bookings = new Dictionary<int, Booking>();
}
public void AddBooking (int bookingID, Booking ..?)
{
}
}
asked 2 mins ago
2 Answers
Vote count:
0
I may be missing something as this seems too easy:
public void AddBooking (int bookingID, Booking booking)
{
this.bookings.Add(bookingId, booking);
}
answered 1 min ago
Vote count:
0
this.bookings.Add(bookingID, booking);
answered 1 min ago
How do you add an object to the dictionary in c#
Aucun commentaire:
Enregistrer un commentaire