Is there a way to do this without using the Type
class? I would rather to use generics.
abstract class MyAbstract
{
protected abstract T GetSpecialType();
private void MyPrivateFunction()
{
someT = GetSpecialType();
}
private void DoSomething<T>()
{
}
}
class MyConcrete : MyAbstract
{
protected override T GetSpecialType()
{
return SomeReallySpecialClass();
}
}
I am sure this would work (its the way I have it now), but its ugly.
abstract class MyAbstract
{
protected abstract Type GetSpecialType();
private void MyPrivateFunction()
{
Type someT = GetSpecialType();
}
private void DoSomething(Type ofT)
{
}
}
class MyConcrete : MyAbstract
{
protected override Type GetSpecialType()
{
return typeof(SomeReallySpecialClas();
}
}
or
Should I put it as a generic parameter on the abstract class?