Why Obsolete causes error? [duplicate]

2019-01-28 00:52发布

This question already has an answer here:

I use:

[Obsolete("Use AnotherMethod() insted.", false)]

2nd parameter is false but Visual Studio shows Warning as Error for every obsolete method call preventing project from compilation. How to make VS mark these calls as Warning not Error?

1条回答
再贱就再见
2楼-- · 2019-01-28 01:07

On the obsolete method define:

#pragma warning disable 0618
        [Obsolete("test",false)]
        private void myMethod()

then go to project properties, under build, in suppress warning type type 0618, Now it will ignore that particular method and project will compile

查看更多
登录 后发表回答