demonstrates the Conditional attribute - CSharp Custom Type

CSharp examples for Custom Type:Attribute

Description

demonstrates the Conditional attribute

Demo Code

#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();
   }
}

Result


Related Tutorials