[ConfigurationProperty("Name", DefaultValue = "test")]
public string Name
{
get { return (string)this["Name"]; }
set { this["Name"] = "Ram"; }
}
CorticonConfig config = new CorticonConfig();
string test = config.Name;
我有一個屬性與「名稱」,我也設置值name.While我嘗試獲取值,我得到默認值。配置DefaultValue行爲
我的問題是:我們可以如上設置屬性值嗎?
Default
值屬性的行爲是什麼?
的http://stackoverflow.com/questions/10506323/canonical-example-of-configurationproperty –
類配置 { \t [的ConfigurationProperty( 「姓名」,默認值= 「測試」)] \t公共字符串可能的複製名稱 \t { get {return(string)this [「Name」]; } set {this [「Name」] =「Ram」; } \t} } 類的setValue { \t公共無效的setValue() \t { \t CorticonConfig配置=新CorticonConfig(); \t config.Name =「test」; \t} } 類當前 { \t公共無效的GetValue() \t { \t \t CorticonConfig配置=新CorticonConfig(); \t \t string test = config.Name; \t} } –
這裏我得到了默認值。 –