Hi there!
I have something like this:
That is very important that those classes cannot be instantiated since their construstors are private so we cannot do like
`public BaseClass<T> Method<T>(int z) where T: BaseClass<T>,` **new()**
How can I use abstract class as return type ?? I just can not work this out. Would appreciate for any assisstance here.
I have something like this:
Code:
abstract class BaseClass<T>
{
protected BaseClass(){}
}
class Class1 : BaseClass<Class1>
{
public static Class1 Instance = new Class1();
private Class1(){}
}
class Class2 : BaseClass<Class2>
{
public static Class2 Instance = new Class2();
private Class2(){}
}
...
public BaseClass<T> Method<T>(int z) where T: BaseClass<T>
{
switch(z)
{
case 1:
return Class1.Instance;
case 2:
return Class2.Instance;
}
}
`public BaseClass<T> Method<T>(int z) where T: BaseClass<T>,` **new()**
How can I use abstract class as return type ?? I just can not work this out. Would appreciate for any assisstance here.
Comment