I\'m using C# and asp.net to query a web service.
The user will enter the number of guests and then I need to add that number of guests to the web service call. Creati
All the other answers have suggested using List
and normally I'd agree - but in this case there's really no need as it seems you know the size beforehand:
Guest[] guests = new Guest[numberOfGuests];
for (int i=0; i < numberOfGuests; i++)
{
Guest guest = new Guest();
// Fill in information about the guest here
// based on the web form
guests[i] = guest;
}
That's not to say you shouldn't use a List
if that's more convenient in any way - it's just that the (probably) biggest benefit of using a List
is that you don't need to know the size in advance. As that's not relevant here (unless I'm missing something) there's not as much reason to use a list.