我有一个测试程序如下:
如果我运行它,它会显示“NULL”。如果我将属性定义移动到Foo类中,则会按预期工作。这是.NET中的一个错误吗?
```
public class FooBase
{
public object Prop {
get { return null; }
private set { }
}
}
public class Foo :FooBase
{
}
class Program
{
static void Main(string[] args)
{
MethodInfo setMethod = typeof(Foo).GetProperty("Prop").GetSetMethod(true);
if (setMethod==null)
Console.WriteLine("NULL");
else
Console.WriteLine(setMethod.ToString());
Console.ReadKey();
}
}
如果我运行它,它会显示“NULL”。如果我将属性定义移动到Foo类中,则会按预期工作。这是.NET中的一个错误吗?