I want to call a simple method group in Linq but I receive this error.
The call is ambiguous between the following methods or properties: 'System.Linq.Enumerable.Select<string,int>(System.Collections.Generic.IEnumerable<string>, System.Func<string,int>)' and 'System.Linq.Enumerable.Select<string,int>(System.Collections.Generic.IEnumerable<string>, System.Func<string,int,int>)'
var num = new [] { "12345", "5432" };
num.Select(Convert.ToInt32);
I understand that there is ambiguity between which method to call. My question is however, is there a way of specifying the signature without calling the method normally. I want to save typing by not having to use lambda expressions.
Thanks.
You could cast explicitly:
num.Select((Func<String, Int32>)Convert.ToInt32);