New Message on dotNET User Group Hyd

C# 2.0 - Part2 ( #Pragma Warning)

Reply
  Reply to Sender   Recommend Message 1 in Discussion
From: Anand Kumar

Hi Folks,

Today I am covering #pragma warning one of the preprocessor directives in C# 2.0.

C# language has many preprocessor directives like #if,#else,#endif  similarly #pragma warning is one type of preprocessor directive .these directives are used to aid in conditional compilation. Unlike C and C++ directives, you cannot use these directives to create macros and preprocessor directive must be the only instruction on a line.

The #Pragma warning directive is used to enable or restore all or certain warning message during compilation .The syntax is

#pragma warning disable warning-list (disable directive disables  the specified set of warnings)
#pragma warning restore warning-list (restore directives restore the specified set of warnings)

if you disable warning externally ( I mean by setting  /nowarn option) # pragma restore will not  enable the warning .

for example disable and restore the CLSCompliant attribute (cs3021)

// pragma_warning.cs
using System;

#pragma warning disable  3021
[CLSCompliant(false)]
public class MyClass
{
   int i = 1;
   public static void Main() // write your code here
   {
    }
}
#pragma warning restore 3021

[CLSCompliant(false)] 

public class MyClass
{
   int i = 1;
   public static void Main() // write your code here
   {
   }
}

Cheeers

Anand

http://spaces.msn.com/members/anandkumar


View other groups in this category.

Click here
Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to