C# #warning preprocessor
In this chapter you will learn:
- #warning directive produces a warning
- Syntax for #warning preprocessor
- Example for #warning preprocessor
- Unused Warning With Warning Suppressed
Description
The #warning
directive produces a warning.
Syntax
The general form of the #warning
directive is
#warning warning-message
Example
Example for #warning
preprocessor
using System;//from w ww . ja v a 2 s. c o m
class MainClass
{
[STAThread]
static void Main(string[] args)
{
#warning Beware!
}
}
The code above generates the following result.
Example 2
Unused Warning With Warning Suppressed
using System;/*from w w w. ja v a 2 s.c o m*/
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
class UnusedWarningWithWarningSuppressed{
#pragma warning disable 0169
int x;
#pragma warning restore 0169
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter: