错误:
public partial class Form2 : Form
可能的原因:
public static IChromosome To<T>(this string text)
{
return (IChromosome)Convert.ChangeType(text, typeof(T));
}
尝试(没有静态关键字):
public IChromosome To<T>(this string text)
{
return (IChromosome)Convert.ChangeType(text, typeof(T));
}
最佳答案
如果您从参数中删除“this”,它应该可以工作。
public static IChromosome To<T>(this string text)
应该是:
public static IChromosome To<T>(string text)
关于c# - 必须在非泛型静态类中定义扩展方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10412233/