【发布时间】:2014-04-17 07:29:33
【问题描述】:
有没有办法将非常量的复杂值或原始值传递给属性?
public class SomeClass
{
private SomeOtherClass _someOtherClass = new SomeOtherClass();
private int _somePrimitiveVariable = CalculateSomeValue();
[MyAttribute(InputValue = _someOtherClass)
public void MyMethod()
{
//Some stuff
}
//Or can it be like this?
[MyAttribute(InputValue = _somePrimitiveVariable)
public void MyMethod()
{
//Some stuff
}
}
【问题讨论】:
-
我猜你不能。在这里查看类似的帖子:stackoverflow.com/questions/1235617/…
-
非常感谢您的 cmets
标签: c# attributes parameter-passing