You seem to not understand delegates and lambda expressions.
A Linq expression based on the
Enumerable
extension methods as
GroupBy
etc. take delegates, usually in the form of lambda expressions.
E.g. the function Select is defined as described in
Enumerable.Select(...)[
^]. It takes a delegate that takes a source item and returns the result item.
E.g.
static int Square(int i) { return i * i; }
static void Main(string[] args)
{
var list = new List<int>() { 1, 2, 3 };
Console.WriteLine(string.Join(", ", list.Select(Square)));
Console.WriteLine(string.Join(", ", list.Select(i=>i*i)));
}
I don't know what your data are, but I guess you want to express something like:
var groupByData = dataCollection.GroupBy(e=>e.it);
No
ToString()
. No clue why you want to convert to string...
Cheers
Andi