我试图为除默认构造函数之外的类型int重载一个构造函数。 我找到的最接近的方法是 这个。
如果不可能,那是为什么呢?
class Program
{
static void Main()
{
//default construcotr get called
var OGenerics_string = new Generics<string>();
//how to make a different construcotr for type int
var OGenerics_int = new Generics<int>();
}
class Generics<T>
{
public Generics()
{
}
// create a constructor which will get called only for int
}
}