我如何标记为过时/德precated的方法? [英] How do I mark a method as Obsolete/Deprecated?
本文介绍了我如何标记为过时/德precated的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何标记使用C#的方法,过时/德precated?
How do I mark a method as Obsolete/Deprecated using C#?
推荐答案
的捷径是:
[Obsolete]
您可以添加一个解释:
[Obsolete("Method1 is deprecated, please use Method2 instead.")]
您也可能会导致编译失败,如果该方法是从什么地方调用code是这样的:
You can also cause the compilation to fail if the method is called from somewhere in code like this:
[Obsolete("Method1 is deprecated, please use Method2 instead.", true)]
(感谢@rick)
(Thanks @rick)
这篇关于我如何标记为过时/德precated的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文