开发者

Obsolete attribute doesn't cause any compiler warning in VS2010

开发者 https://www.devze.com 2022-12-31 18:07 出处:网络
I\'m using Visual Studio 2010. But find开发者_如何学Go that the Obsolete attribute doesn\'t cause any compiler warning (I want it to cause a compiler warning).

I'm using Visual Studio 2010. But find开发者_如何学Go that the Obsolete attribute doesn't cause any compiler warning (I want it to cause a compiler warning). The warning level is 4.

Thanks.


The obsolete attribute will cause a compiler warning when you try to use the class/method that's marked with it. For example the following causes a warning:

[Obsolete("some obsolete message")]
class Foo { }

class Program
{
    static void Main(string[] args)
    {
        Foo foo = new Foo();
    }
}

while this doesn't:

[Obsolete("some obsolete message")]
class Foo { }

class Program
{
    static void Main(string[] args)
    { }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消