• ObsoleteAttribute



Marks the program elements that are no longer in use(标志某些程序的元素不再推荐使用了)

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]

public sealed class ObsoleteAttribute : Attribute

{

   public ObsoleteAttribute();

   public ObsoleteAttribute(string message);

   public ObsoleteAttribute(string message, bool error);

   public bool IsError { get; }

   public string Message { get; }

}


Sample:

[Obsolete("Thread.Resume has been deprecated.  Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.  http://go.microsoft.com/fwlink/?linkid=14202", false)]
        public void Resume();