Cannot Convert from Method Group to Object - C#

前端 未结 6 1925
野趣味
野趣味 2021-01-12 03:23

I am trying to get familiar with C# and tried out the following program - it just outputs the average of the even numbers in the Array.

6条回答
  •  醉话见心
    2021-01-12 03:53

    The Missing Parenthesis () is the reason for your error.It should be Average()

    without a Parenthesis,it is understood as a method group.The average method could have multiple overloads and it is unclear which specific overloaded method needs to be invoked.But when you mention the parenthesis it makes the intention clearer and the method gets called.

提交回复
热议问题