I have the following code that splits a string on newlines and converts it to a Dictionary for further processing:
string[] splitProgram = program.Split(Environment.NewLine.ToCharArray());
short i = 0;
Dictionary<short, string> programDictionary = splitProgram.ToDictionary<short, string>((value) => i++);
What's odd is i get the following errors on the third line:
Error 1 Instance argument: cannot convert from 'string[]' to 'System.Collections.Generic.IEnumerable<short>'
Error 2 'string[]' does not contain a definition for 'ToDictionary' and the best extension method overload 'System.Linq.Enumerable.ToDictionary<TSource,TKey>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TKey>)' has some invalid arguments
Error 3 Argument '2': cannot convert from 'lambda expression' to 'System.Func<short,string>'
I'm absolutely stumped on this and can't figure it out. Can someone help?