任何人都可以解释为什么静态属性为空?静态属性抽象类
class Program
{
static void Main(string[] args)
{
string s = Cc.P1; // is null
}
}
public class Cc
: Ca
{
static Cc()
{
P1 = "Test";
}
}
public abstract class Ca
{
public static string P1
{
get;
protected set;
}
}
在一个侧面说明,这就是为什么ReSharper的会骂你,如果你尝试做这样的事情(通过导出指静态字段类)。 – 2010-09-30 09:58:14
我读过这个问题:http://stackoverflow.com/questions/774181/why-cant-i-inherit-static-classes,你知道我怎么能做到这一点?静态属性不支持接口 – fravelgue 2010-09-30 10:56:30
@fravelgue,你怎么能做什么?你没有解释你正在尝试做什么... – 2010-09-30 12:03:19