Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VB.NET, can I mark a function as deprecated?

Is there an ability in VB.NET to deprecate code? I know that in C# there are 'attributes', and tags in java; is there anything similar in VB.NET, other than leaving a 'todo:...?

like image 790
brasskazoo Avatar asked Mar 16 '09 00:03

brasskazoo


People also ask

How do you mark a method deprecated?

In you examples the "Method1 is deprecated" part is rather redundant. By marking it as obsolete you are saying that it is indeed obsolete, so no need to restate it in the message. Especially since the resulting warning/error will read 'Method1' is obsolete: 'Method1 is deprecated, please use Method2 instead. '

How do you mark a class deprecated?

You need to use the [Obsolete] attribute. Example: [Obsolete("Not used any more", true)] public class MyDeprecatedClass { //... }

Is VB Net deprecated?

Visual Basic (VB.NET) will continue to be supported by Microsoft. (It's not dead.) The language will no longer have new features added to it.

How do you make a method deprecated in C#?

This attribute is found in the System namespace. The Obsolete attribute decorates a program element by putting the word “Obsolete” above it inside square brackets. Since it is an attribute, we can use either Obsolete or ObsoleteAttribute. [Obsolete] − is a no parameter constructor and is a default using this attribute.


2 Answers

There are attributes in VB.NET too:

  • https://msdn.microsoft.com/en-us/library/system.obsoleteattribute(v=vs.110).aspx
  • http://www.vb-helper.com/howto_net_obsolete_attribute.html

Looks like this (before your function)

<Obsolete("This method is deprecated, use XXXX instead.")> _ 

And since VB.NET 10 (.NET 4 and later) we no longer need the underscore.

<Obsolete("This method is deprecated, use XXXX instead.")>
like image 99
Lou Franco Avatar answered Oct 19 '22 23:10

Lou Franco


Use the [Obsolete] Attribute.

like image 8
Otávio Décio Avatar answered Oct 19 '22 21:10

Otávio Décio