Sequence contains no matching element

前端 未结 5 2136
滥情空心
滥情空心 2020-11-30 00:48

I have an asp.net application in which I am using linq for data manipulation. While running, I get the exception \"Sequence contains no matching element\".

i         


        
5条回答
  •  臣服心动
    2020-11-30 01:27

    From the MSDN library:

    The First(IEnumerable) method throws an exception if source contains no elements. To instead return a default value when the source sequence is empty, use the FirstOrDefault method.

提交回复
热议问题