开发者

Obsolete attribute doesn't cause any compiler warning in VS2010

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜