What is the difference between FirstorDefault() and SingleorDefault() in LINQ ?

SingleorDefault() requires that one and only one element exists in the sequence. But FirstorDefault() simply gives you the first one or top one in the sequence. Both assert that at least one exists and both returns default or null value if nothing exists in sequence.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...