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)
{ }
}
精彩评论