How to get first object out from List<Object> using Linq

前端 未结 10 1355
自闭症患者
自闭症患者 2020-12-29 00:51

I have below code in c# 4.0.

//Dictionary object with Key as string and Value as List of Component type object
Dictionary>         


        
10条回答
  •  情深已故
    2020-12-29 01:33

    You also can use this:

    var firstOrDefault = lstComp.FirstOrDefault();
    if(firstOrDefault != null) 
    {
        //doSmth
    }
    

提交回复
热议问题