1. public class TestClass
    2. {
    3. // 添加Obsolete特性
    4. [System.Obsolete("请使用新的SendMsg()")]
    5. public static void ShowMsg()
    6. {
    7. }
    8. public static void SendMsg()
    9. {
    10. }
    11. }
    12. class Program
    13. {
    14. static void Main(string[] args)
    15. {
    16. TestClass.ShowMsg();
    17. }
    18. }

    C# 特性之Obsolete - 图1