Let’s say I have a list of objects TheListOfObjects.
If I write this:
TheListOfObjects = TheListOfObjects.Take(40).ToList();
Will it crash if there are only 30 items in the list or will it just return the first 30? And when TheListOfObjects is empty, or even null?
Thanks.
This is one of those where you should just try it or at least check the documentation.
It will just return the first 30.
It will return the empty sequence.
It will result in a
ArgumentNullException.From MSDN:
And under exceptions:
In the time it took you to log on to StackOverflow, you could have either checked MSDN and got an authoritative answer (notice that some mildly incorrect or partially incomplete answers have already been posted and deleted here) or fired up Visual Studio and greased your wheels a little bit.