Wie Sie einen index in einer var in LINQ?

Ich versuche, das folgende Stück code, zur Arbeit in LINQPad, bin aber nicht in der Lage, um den index in eine var. Weiß jemand, wie man einen index in eine var in LINQ?

string[] sa = {"one", "two", "three"};
sa[1].Dump();

var va = sa.Select( (a,i) => new {Line = a, Index = i});
va[1].Dump();
//Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<AnonymousType#1>'
InformationsquelleAutor Guy | 2008-09-04
Schreibe einen Kommentar