Compilation Error due to IEnumerable.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Ive written below method:internal static IEnumerable<T> GetNumbersAndCheckWhoseValueMatchIndexInArray<T>(int[] numbers)
{
return numbers.Select((digit, index) => new { Digit = digit, InPlace = (digit == index) });
}
I get the below compilation error:
Error 2 Cannot implicitly convert type System.Collections.Generic.IEnumerable<AnonymousType#1> to System.Collections.Generic.IEnumerable<T>. An explicit conversion exists (are you missing a cast?) E:My AppsJustForPracticeJustForPracticeRandomFunctions.cs 65 20 JustForPractice
What is appropriate return type for this method? Also, please explain why <T> wouldnt work and what is <AnonymousType#1> (Im seeing this for the first time.)
Busiest mind writes minimum code.

View the full article
 
Back
Top