在 VB.NET 中,我可以将函数标记为已弃用吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/648876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 14:07:53  来源:igfitidea点击:

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

vb.netfunctiondeprecated

提问by brasskazoo

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:...?

VB.NET 中是否有能力弃用代码?我知道在 C# 中有“属性”和 Java 中的标签;VB.NET 中有没有类似的东西,除了留下一个'todo:......?

回答by Lou Franco

There are attributes in VB.NET too:

VB.NET 中也有属性:

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.

从 VB.NET 10(.NET 4 及更高版本)开始,我们不再需要下划线

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

回答by Otávio Décio

Use the [Obsolete] Attribute.

使用 [Obsolete] 属性。