Author - StudySection Post Views - 1,580 views
obsolete-methods

How to resolve build warning for obsolete methods (CS0612) in C#

Description: While working with the projects, sometimes we have some deprecated methods called in our code and when we build the solution, we see lots of warnings. Though these warnings do not affect the running of projects in most cases, we should avoid having these warnings as much as possible. We do not want our build logs to fill with such clutter of warnings.

Definition: The meaning of the warning is basically to inform us that it is possible that this method may not be supported by the future version of the class.

The warning for obsolete methods looks something like this:
build
When we go to the definition of these methods, we will see the obsolete attribute above the method definition like below:
code
Solution: We can resolve or disable this kind of warning in the build logs by using the pragma statements just above the statement which is causing this warning and the one pragma statement just below that line to restore warnings as I did in the screenshot below:
Solution
#pragma warning disable 612, 618
#pragma warning restore 612,618

So the warning for this obsolete method will no longer show in the build logs.
Note: I am keeping some part of the actual code blurred for security reasons.

Get certification for your knowledge in the fundamentals of Computer functioning by clearing the Computer Certification exam conducted by StudySection. After going through this Computer Certification exam, you will be able to evaluate your basic knowledge of computers

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri