Bla*_*ise -1 c# generics enums
试图模仿这篇文章:创建将T限制为枚举的通用方法
public static string[] ToTextArray(this Dictionary<string, T> dictionary) where T:struct, IConvertible
{
...
}
Run Code Online (Sandbox Code Playgroud)
看来我T无法解决.为所有Dictionary<string, enum_type>类编写扩展方法的正确方法是什么?
您在方法声明中缺少泛型类型参数:
public static string[] ToTextArray<T>(this Dictionary<string, T> dictionary)
where T: struct, IConvertible
Run Code Online (Sandbox Code Playgroud)