James Ramsay

James Ramsay

  • NA
  • 3
  • 1.5k

vb.net function to C# conversion

Jun 12 2011 9:30 PM
Hi All,

I am trying to convert a simple function from vb.net to c# but am runing into problmes.

The vb.net function is


Private Function GetTopValues(ByVal stocks As Dictionary(Of MySymbolScript, Double), ByVal count As Integer) As IEnumerable(Of KeyValuePair(Of MySymbolScript, Double))Return (From stock In stocks Order By stock.Value Descending).Take(count)End Function

and converted to c# I get:

private IEnumerable<KeyValuePair<MySymbolScript, double>> GetTopValues(Dictionary<MySymbolScript, double> stocks, int count)
{
return (from stock in stocks orderby stock.Value descending).Take(count);
}

The problem is at the ) after the word descending it says "Error 1 A query body must end with a select clause or a group clause"

Any ideas? I have treid a few variations but nothing seams to work for me.

Thanks.
James

Answers (2)