读代码学到新知识

1.AttributeUsage的应用(用于指定一个Attribute的应用范围)

 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
  public class DependencyAttribute : Attribute
  {

     ..

 }

 

2. 为方法参数设置默认值的写法

 public class Man    

{        

       public string Name;        

       public int Age;

       public Man(string name = "123", int age = 1)       

       {             this.Name = name;             this.Age = age;         }  

   }

posted on 2015-02-28 10:41  micrsoft  阅读(142)  评论(0编辑  收藏  举报

导航