Conditional attributes

Conditional attributes tell the compiler to ignore a call to a method or a class if the flag is not defined.


#define TESTMODE
using System;
using System.Diagnostics;
class Program
{
    static void Main()
    {
        Console.WriteLine("in test mode!"); // OUTPUT: in test mode!
    }
    [Conditional("LOGON")]
    static void YourMethod(string msg)
    {
    }
}

The output:


in test mode!
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.