Introduction

In this blog, we are discussing how we can mark the method as deprecated, with the help of a simple program we can understand: method deprecation.

What is method deprecation?

I have created a console application with a simple class. In the class, I have two methods, those are addition and an improvised method of addition or the existing method. Now you want to tell your developer who is consuming the method addition instead of the addition method, and from now on it will consume improvised addition method.

public void adition()  
       {  
           // intially created method , consumed by developers   

       }  

       public void improvised_adition()  
       {  
           // imrovised the addition method , for example may code fine tuneing.  

       }  

Now the question is, how to say the method is deprecated?

It is very simple-- please use the obsolete attribute. Please check the below code sample.

    [Obsolete] // using attribute.
        public void adition()  
        {  
            // intially created method , consumed by developers   

        }  

#c# #csharp #programming-c

Method Deprecation In C#
1.30 GEEK