I have the following static function:
public static string codeList<T>(List<T> thelist, Func<T, string> coder);
using this function with my own objects is not a problem, for example:
string code = codeList<MyClass>(myclassList, MyClass.code);
Where MyClass.code is a static function (defined in MyClass) that receives MyClass and returns a string.
The problem is that when I try to use this function using List<int> or List<double> , what I am doing now predetermines statics like Func<int,string> intCoder = (x) => x.ToString(); and Func<double,string> (x) => x.ToString(); and uses them. Is there any other way to do this? sort of:
string code = codeList<int>(intList, Int32.ToString);
source share