使用Action创建我自己的Attribute作为参数类型

时间:2014-06-11 12:08:32

标签: c# .net custom-attributes

我想在Attribute中使用C# .Net类型的参数创建我自己的Action,如下所示:

 public class TestAttribute : Attribute
 {
        public Action MethodToExecute;
 }

使用:

 [TestAttribute(MethodToExecute = () => Test())]
 public string VersaoLinha { get; set; }

 public static string Test()
 {
     return string.Empty;
 }

但是,我有错误Is not a valid argument because it is not a valid attribute parameter type。有办法做到这一点吗?

0 个答案:

没有答案
相关问题