我试图重载默认构造函数之外的构造函数,只会调用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
}
}
Run Code Online (Sandbox Code Playgroud)