我試圖做到這一點的自動變量名:什麼是自動實現的屬性
public string LangofUser
{
get
{
return string.IsNullOrEmpty("how to get value?") ? "English" : "how to get value?";
}
set;
}
我必須這樣做嗎?
string _LangofUser
public string LangofUser
{
get
{
return string.IsNullOrEmpty(_LangofUser) ? "English" : _LangofUser;
}
set { _LangofUser = value};
}
你必須這樣做第二種方法。第一個是不可能的。 –
「什麼是自動實現的屬性的自動變量名稱」後臺字段是匿名的。這意味着它沒有名字。 – BoltClock
可能重複[C#屬性:如何使用自定義設置屬性沒有私人領域?](http://stackoverflow.com/questions/4833635/c-sharp-properties-how-to-use-custom-set-property-沒有私人領域) – nawfal