如何标记一个类已过时? [英] How to mark a class as Deprecated?

查看:507
本文介绍了如何标记一个类已过时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
如何标记方法过时/已过时? - C#

你如何标记一个类为过时的
?我不希望在我的项目中使用的一类了,但是不想要一个为期2周之前将其删除。

How do you mark a class as deprecated? I do not want to use a class any more in my project, but do not want to delete it before a period of 2 weeks.

推荐答案

您需要使用属性 [作废]

这是一个例子:

[Obsolete("Not used anymore",true)]
public class MyDeprecatedClass
{
	//...
}

您不必使用的参数,它们是可选的(重载方法)。第一个参数是对的原因,最后一个是标记在编译的时候,而不是一个警告错误。

You do not have use parameters, they are optional (overloaded method). The first parameter is for the reason and the last one is to mark an Error in compile time instead of a warning.

这篇关于如何标记一个类已过时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆