【发布时间】:2015-12-31 08:15:32
【问题描述】:
我有一个包含一堆属性的类。现在我将在运行时为这些属性添加或消除一些属性,但我不知道我应该如何做。
班级
Class myClass
{
//Other codes
public string DetailedAccountTitle
{
get { return detailedAccountTitle; }
set { detailedAccountTitle = value; }
}
//Other codes
}
调用者内部
if ((bool)e.Value)
{
//Add the attribute
}
else
{
//Eliminate it
}
现在你可以看到我正在控制调用者内部的一个事件,我希望它在它为真时添加属性,如果不是,则消除它。
【问题讨论】:
-
您是否为此尝试过任何代码示例?
-
旁注:你可以写成
public string DetailedAccountTitle { get; set; } -
@guy 我知道。反正 tnx :)
-
您是否正在研究类似的内容:stackoverflow.com/questions/2483124/…?
-
看看this
标签: c# attributes