I have 2 instances:
foo and bar
Their types are:
foo.GetType().ToString()
returns: System.Collections.Generic.List`1[MyNameSpace.MyClass]
bar.GetType().ToString()
returns: System.Collections.Generic.List`1[MyNameSpace.MyClass]
When I concatanate them:
var foobar = foo.Concat(bar);
The GetType() returns System.Linq.Enumerable+d__71`1[MyNameSpace.MyClass]
Question: What does this mean? Should not it be IEnumerable ?
Don't confuse the declared return type and the actual type of the returned value. Concat
is declared to return IEnumerable<T>
, but it actually returns an instance of a concrete type that implements IEnumerable<T>
. GetType
returns the concrete type, not the declared return type.
As for the weird name, Concat
is implemented with an iterator block, and iterator blocks are transformed by the compiler into types with names such as Enumerable+d__71
that implement IEnumerable<T>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With