c# - What's the difference between the two processes? -


the first 1 using ienumerable single method , has invalidoperationexception.

rowobjecttype = rowobjectassemblytypes.single(type => type.name == rowobjecttypename); 

i think second 1 same thing first 1 , works fine.

foreach (var type in rowobjectassemblytypes)         {             if (type.name == rowobjecttypename)             {                 rowobjecttype = type;             }         } 

i'm using .net3.5. can tell me difference between them?

the first 1 crashes because there 0 items or more 1 item. bug , single alerted that!

the loop doesn't care. might never assign rowobjecttype or multiple times. that's semantically not want.

if expect 0 items use singleordefault.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -