c# - How to get the sum of list of shorts using the extension method Sum()? -


I was trying to do something like this -

  list & lt; Short> Listofshorts = New list & lt; Short> (); Int s = listofshorts.Sum (); // This does not work ... but works for the same code ints list.  

I found this compilation error -

'System Collections. There is no definition for 'yoga' in Generic.List and there is some invalid argument in the best extension method overload 'System.Linq.Queryable.Sum (System.Linq.IQueryable)'.

< P> Can someone suggest how can I use an extension method to calculate the sum of shorts? The extension method does not support it for some reasons ...

  int s = listofshorts sum ( D = & gt; D);  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -