forum

home / developersection / forums / understanding .single()

Understanding .Single()

Anonymous User 1849 23-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

}


c# c# 
Updated on 23-Aug-2014

I am a content writter !


Message
Can you answer this question?

Answer

1 Answers

Liked By