Attribute属性

1.在方法前面加[]

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Collections;
using System.Threading.Tasks;
namespace test
{
  public class teste {
      [Conditional("Debug")]
      public static void attr(){
      Console.WriteLine("123456");
      }
      [Obsolete("这是一个老旧的方法")]
      public static void obso() {
          Console.WriteLine("obsolete");
      }

      static void Main()
      {
          attr();
          obso();
          Console.ReadKey();
      }
   }
  }
View Code

 

posted @ 2017-04-22 00:26  ADFL  阅读(145)  评论(0编辑  收藏  举报