【发布时间】:2011-04-05 21:38:52
【问题描述】:
我在c#中有以下课程,应该很容易理解
public abstract class BaseAbstract
{
public void PrintMethodNames()
{ // This line might needs change
foreach (PropertyInfo pi in typeof(BaseAbstract).GetProperties())
{
Console.WriteLine(pi.Name);
}
}
}
public class DerivedClass : BaseAbstract
{
public void MethodA() { }
public void MethodB() { }
public void MethodC() { }
}
public class MainClass
{
public static void Main()
{
BaseAbstract ba = new DerivedClass();
ba.PrintMethodNames();
// desired printout
// MethodA
// MethodB
// MethodC
// but obviously not working
}
}
那么我在寻找什么?
【问题讨论】:
标签: c# reflection inheritance abstract-class