c# - Can a ForEach lambda expression have an optional return type -


is there way foreach lambda expression have optional return type. here pseudo code example of needs achieved:

string val = mylist.foreach(listitem => { if(listitem == "yes" ){ return "found" }  });  if(val == "found"){ dosomething } 

no, foreach wrong method result. use any:

bool found = mylist.any(listitem => listitem == "yes"); 

Comments

Popular posts from this blog

Prolog - Listing -

orchardcms - change base url in local copy in Orchard CMS -

linear regression - Trying to get confidence/prediction intervals with `predict.lm` in R, but I keep getting an error regarding my dichotomous variable -