CSharp examples for Custom Type:Attribute
demonstrates the Conditional attribute
#define DEBUG/*from w w w . ja v a 2s.c o m*/ using System; using System.Diagnostics; public class Myclass { [Conditional("DEBUG")] public static void Message(string msg) { Console.WriteLine(msg); } } class Test { static void function1() { Myclass.Message("In Function 1."); function2(); } static void function2() { Myclass.Message("In Function 2."); } public static void Main() { Myclass.Message("In Main function."); function1(); } }