forum

Home / DeveloperSection / Forums / Understanding .Single()

Understanding .Single()

Anonymous User164623-Aug-2014

Browsing sample code I'm seeing a usage I don't understand:

var orderRow = order.Rows.Single();

Rows is an enumerable and usually one would iterate using a foreach loop. Is the .Single a workaround for cases where, for whatever reason, the foreach can't be (or need not) be used?

var option = options.OfType<AdditionalLocationsOption>().SingleOrDefault();

if (option != null){

...stuff

}


Updated on 23-Aug-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By