Reputation: 3577
I have a generic method that has several parameters plus a return type:
public static class Support
{
public static TR JSONKeyName<TR, T1, T2, T3>(this IEnumerable<Tuple<T1, T2>> a, Action<T3> b)
{
TR result = default(TR);
try
{
foreach (var entry in a)
{
b((T3)TypeDescriptor.GetConverter(typeof(T3)).ConvertFromInvariantString("[ \"" + entry.Item1 + "\", " + entry.Item2 + "\" ]"));
}
result = (TR)Convert.ChangeType(true, typeof(TR));
}
catch
{
result = (TR)Convert.ChangeType(false, typeof(TR));
}
return result;
}
}
List<Tuple<int, string>> list = new List<Tuple<int, string>>();
list.Add(new Tuple<int, string>(1, "Test 1"));
list.Add(new Tuple<int, string>(2, "Test 2"));
list.Add(new Tuple<int, string>(3, "Test 3"));
var res = list.JSONKeyName<bool>((string entry) =>
{
});
When calling JSONKeyName from the example above I get the following error:
The compiler error is:
*Using the generic method requires 4 type arguments
Upvotes: 0
Views: 2345
Reputation: 225291
Er, you've noticed that it takes multiple arguments, and you're obviously passing it only one — bool
. Change it to list.JSONKeyName<bool, int, string, string>
, as per the context.
Upvotes: 2