What will be the output of below code?

List<int> lst = new List<int>();
lst.Add(1);
lst.Add(2);
bool exists = lst.Exists(value => value >= 2);

 Posted by Rajesh_Kumar on 1/18/2014 | Category: C# Interview questions | Views: 833 | Points: 40
Answer:

It will return True.Because as we can see list have 2 items as 1 and 2.And we are checking value >= 2(value is greater than or equal to 2).So the condition will always be True.It's same as we check with IF condition.As IF condition returns True or False.Exists also returns True or False.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response