C# #warning preprocessor

In this chapter you will learn:

  1. #warning directive produces a warning
  2. Syntax for #warning preprocessor
  3. Example for #warning preprocessor
  4. 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:

  1. Get to know Array.IsFixedSize
  2. Syntax for Array.IsFixedSize
  3. Example - Array.IsFixedSize
Home »
  C# Tutorial »
    C# Types »
      C# Preprocessor
C# preprocessor
C# #define Preprocessor
C# #if Preprocessing Directive
C# #elif Preprocessing Directive
C# #undef
C# #line directive
C# #region directive
C# #warning preprocessor