我的基类使用派生类的反射来为它们提供一些功能。目前我这样做:
abstract class BaseClass<T>
{
string GetClassString()
{
// Iterate through derived class, and play with it's properties
// So I need to know the type of derived class (here T).
return result;
}
static bool TryParse(string classString, out T result)
{
// I should declare a variable as T and return it
}
}
我可以在没有泛型的情况下做到这一点吗?