Nick,
I suppose you could do the following.
schedule.jobs.FindLast(delegate(Job x) { return true; });
That's assuming that FindLast actually starts it search from the last
item. It's pretty ugly if you ask me.
A lambda expression would be pretty elegant; perhaps more so than the
.Count - 1 technique.
schedule.jobs.FindLast(x => true);
You'll have to wait until C# 3.0 for that though.
Brian
Nick said:
Nothing wrong.
I can't remember where (book or site etc) but I would swear I have seen a
better way to get the last index of a generic list.
Like a property, eg : schedule.jobs.getlastitem.tasks.add( ...);
But I can't find it now, so I guess it was in my imagination, or perhaps
a
different language ;-)
With regards,
Nick
Daniel said:
What's wrong with using that code?
Is there a way to get the last item added to a generic list? That is,
without using the count property.
Something to improve this code:
schedule.jobs[schedule.jobs.Count-1].tasks.Add( ... );
With regards,
Nick