2
Answers

vb.net function to C# conversion

Ask a question
James Ramsay

James Ramsay

13y
1.3k
1
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)