The Enumerable.Select
method is an extension method for an IEnumerable<T>
type. It takes a Func<TSource, TResult>
that allows you to take in your IEnumerable<T>
items and project them to something else, such as a property of the type, or a new type. It makes heavy use of generic type inference from the compiler to do this without <>
everywhere.
In your example, the IEnumerable<T>
is the string[]
of lines from the file. The Select
func creates an anonymous type (also making use of generic type inference) and assigns some properties based on splitting each line l
, which is a string
from your enumerable.
OrderBy
is another IEnumerable<T>
extension method and proceeds to return an IEnumerable<T>
in the order based on the expression you provide.
T
at this point is the anonymous type from the Select
with two properties (myIdentiafication
and myName
), so the OrderBy(i => i.Id)
bit won't compile. It can be fixed:
.OrderBy(i => i.myIdentiafication);