Meskipun C dibuat untuk memprogram sistem dan jaringan komputer namun bahasa ini juga sering digunakan dalam mengembangkan software aplikasi. C juga banyak dipakai oleh berbagai jenis platform sistem operasi dan arsitektur komputer, bahkan terdapat beberepa compiler yang sangat populer telah tersedia.
C adalah huruf ketiga dalam alfabet Latin. Dalam bahasa Indonesia, huruf ini disebut ce (dibaca [tʃe]).
Use #pragma warning disable
:
using System;
class Test
{
[Obsolete("Message")]
static void Foo(string x)
{
}
static void Main(string[] args)
{
#pragma warning disable 0618
// This one is okay
Foo("Good");
#pragma warning restore 0618
// This call is bad
Foo("Bad");
}
}
Restore the warning afterwards so that you won't miss "bad" calls.
The intent is to disable the warning for obsolete usage, regardless of whether the construct is marked with [Obsolete]
or [Obsolete("Message")]
. So use both CS0612 and CS0618:
#pragma warning disable 612, 618
...
#pragma warning restore 612, 618
Here's how to get the warning/error number in the first place:
C:\Users\Username\Documents\Visual Studio 2010\Projects\Projectname\Classname.cs(203,7): warning CS
0162
: Unreachable code detected
CS
".(Better always proceed as Jon Skeet says…)
You're looking for the #pragma
warning disable directive
Essentially you add the following command above the call site in the .cs file.
#pragma warning disable 612
SomeMethodCall
612 is the error message ID for calling obsolete methods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With