LINQ: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'int'

前端 未结 4 1018
孤城傲影
孤城傲影 2021-01-19 01:19

I get an error from the following code:

int dreamX[];

private void Form1_Load(object sender, EventArgs e)
{ 
    sumX();
}

private void sumX()
{
    for (v         


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-19 01:55

    FirstOrDefault() will turn the IEnumerable into an int.

    Actually it takes the first occurance in the outputresult of your linq-query.

提交回复
热议问题