Hullo,
For some reason (that I can't work out) a function that returns an ilist keeps returning null when I call it (even though earlier in the same method it returns an empty ilist, but whatever) so I was making a function to take in several ilists and then output the total number of elements across all the lists (ignoring the null ones as to avoid an exception).
So far I have:
private int TotalItemsInLists(params IList[] lists)
{
int total = 0;
foreach (IList list in lists)
if (list != null)
total += list.Count;
return total;
}
but that causes problems in that params IList[] lists doesn't seem to be called correctly, as the ILists are all lists of different types.
Anyone know how I can remedy this problem?
Thanks, Harry
Edit: Here is the code that calls it
private bool TooManyItems(Person person)
{
return TotalItemsInLists(jobService.BeingDevelopedBy(person), jobService.BeingTestedBy(person),
jobService.BeingFixedBy(person), quoteService.BeingProducedBy(person),
ticketService.BeingActivelyHandledBy(person),
ticketService.BeingTestedBy(person),
ticketService.AllAvailable(person)) > 10;
}
And here's an example of one of the methods they call (they're all pretty similar, just different databases and filters)
public IList<Ticket> BeingActivelyHandledBy(Person person)
{
return (from ticket in Query()
where ticket.Handler == person
&& ticket.Status == TicketStatus.Open
&& ticket.Release == null
select ticket).ToList();
}