我有一些类Item
其中包含一个字段重构常量字符串
public const string Root = "/homepage";
不幸的是,事实证明这个字符串不是常量!
当我试图重新定义为说
public string Root = DoSomething("/homepage");
或财产
public string Root
{
get {
return DoSomething("/homepage");
}
}
我得到两种不同类型的错误
A field initializer cannot reference the non-static field, method, or property 'Item.Root'
的,这一次打一顿,我认为可能是一个更大的问题
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
我真的不确定如何解决这个问题,没有一个严肃的重构练习。有什么建议?
@IvanStoev你是对的,我错过了第二个错误。谢谢! – dasblinkenlight
谢谢,至少现在我*知道*我是scr **编辑。 – inspite
@inspite您是否遇到了您自己的某个属性问题,或者是您无法更改的问题? – dasblinkenlight