Using the OBSOLETE Flag code in C # expires

Source: Internet
Author: User

The project was updated today, and a new class was created to replace the original work. But do not want to delete, once deleted on the SVN will not exist. Decide whether to use obsolete to sign the code out of date.


Introduction to the obsolete tag on MSDN

Https://msdn.microsoft.com/zh-cn/library/22kk2b44%28VS.80%29.aspx

The Obsolete property marks a program entity as an entity that is not recommended for use. Each time you use an entity that is marked as obsolete, a warning or error is subsequently generated, depending on how the property is configured.


Obsolete tags for classes, functions, respectively, in the sample code

Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; namespace obsoletetest{    [Obsolete ("A was Obsolete,use C")]    class a{}    [Obsolete ("B is Obsolete,use C", true)]    class b{}    class c{}    class program    {        [Obsolete ("Funca is Obsolete,use FunC")]        static void Funca () {}        [Obsolete ("FUNCB is Obsolete,use FunC", true)]        static void Funcb () {}        static void Funcc () {}
   static void Main (string[] args)        {            Funca ();            FUNCB ();            A = new A ();            b b = new B ();}}}    

After compiling, vs prompts for errors and warnings


Copyright NOTICE: This article transferred from Http://blog.csdn.net/huutu Reprint please take the http://www.thisisgame.com.cn

Using the OBSOLETE Flag code in C # expires

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.