Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Convert from Method Group to Object - C#

Tags:

c#

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.

Code SnippetErrors

Would be great if someone could highlight the problem here.

like image 763
Hari Avatar asked Oct 29 '12 04:10

Hari


2 Answers

You need select.Average() (with the parens).

like image 133
Andrew Cooper Avatar answered Oct 21 '22 17:10

Andrew Cooper


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.

like image 42
Prabhu Murthy Avatar answered Oct 21 '22 17:10

Prabhu Murthy