Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we mark a overloaded method obsolete?

Tags:

c#

.net

I have two functions: Method(A val) and Method(B val), one taking val of type A and the other of type B.

I want to mark Method(A val) obsolete, so that IDE can highlight the fact that it's obsolete.

I have decorated the method with [Obsolete], however, am not seeing it as deprecated.

Am I missing something? From my research, I have only seen examples of creating a brand new method to replace the old one but not seen any example of a overloaded function taking place of the older deprecated one. Any help would be highly appreciated.

like image 287
user420 Avatar asked Mar 20 '23 22:03

user420


1 Answers

Intellisense doesn't consider just a single overload depreciated; it considers an entire method deprecated in what it shows.

If we look at the entire method's Intellisense popup:

enter image description here

compared to the popup for a particular overload:

enter image description here

But the key point is that once we have a completed call to the method, the deprecated overload results in a warning (or error):

enter image description here

while the other does not:

enter image description here

like image 78
Servy Avatar answered Mar 29 '23 05:03

Servy