InvalidOperationException: Sequence contains more than one element

后端 未结 1 1908
渐次进展
渐次进展 2021-01-02 05:30

I have the following code below for a payroll program. The first dictionary holds the employee IDs and corresponding basic pays held in a master data table. The second dict

相关标签:
1条回答
  • 2021-01-02 05:54

    You can use FirstOrDefault() but SingleOrDefault throws an exception if more than one element exists.

    Here you can see exactly what the single or default method does: http://msdn.microsoft.com/en-us/library/system.linq.enumerable.singleordefault(v=vs.100).aspx

    0 讨论(0)
提交回复
热议问题