LINQ to Objects auto increment number LINQ to Objects auto increment number asp.net asp.net

LINQ to Objects auto increment number


Pardon me for doing this in C# not sure exactly the syntax in VB.NET:

MasterCalendarInstance    .OrderBy(x => x.Key)    .Select((x, ixc) => new { CalendarId = x.Key, Iter = ixc });


I don't know if this is possible in VB, but in C# one uses a closure:

int count = 0var res = from x in MasterCalendarInstance          order by x.Key          select new {            CalendarId = x.Key,            Iter = count++          };


The above solutions could be summed up in VB.NET like this :

MasterCalendarInstance _    .OrderBy(Function (x) x.Key) _    .Select(Function (x, ixc) New With { .CalendarId = x.Key,                                         .Iter = ixc })