Click here to Skip to main content
15,179,684 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
For the record I have been on Google for hours trying to get more examples of this method, (The pages are more purple than a person's wardrobe who is a fanatic for the color.) so I am going to go strait to the question. Would you give me examples of use of the TrueForAll Method in the Generic List, specifically to check if all the List's objects are null and if the List is empty. Please keep the answers simple but not too simple that it gives me no usable information. Thank you very much in advance. I appreciate every answer. Have a good day. :)
Sergey Alexandrovich Kryukov 21-Jul-13 21:51pm
Why, why an example? Why searching for such examples? First of all, you should try to right code by yourself. If everyone would try to find some code, where the codes would come from? Reading of MSDN help pages should be more than enough.

1 solution

List<object> items = new List(); 

//Add items, etc...

if (items.TrueForAll(item => item == null))
  //Everything is null

For the empty, just do:

if (items.Count == 0)
Sergey Alexandrovich Kryukov 21-Jul-13 21:54pm
Correct answer, a 5, but OP doesn't really deserve it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900