How to check if all array elements are non-negative?

 Posted by Niladri.Biswas on 6/13/2013 | Category: C# Interview questions | Views: 2480 | Points: 40
Answer:

If we actually want to check they're all non-negative (i.e. 0 is acceptable) use:

bool allNonNegative = array.All(x => x >= 0);


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response