Advertisement
splash5

Conditional Sample

Sep 6th, 2017
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. // This define is only affect in this .cs file
  2. // Try global define if need to affect every .cs file
  3. #define ENABLE_FUNCTION
  4.  
  5. using System;
  6. using System.Diagnostics;
  7.  
  8. public static class Sample
  9. {
  10.     public static void Test()
  11.     {
  12.         // This will be called only when ENABLE_FUNCTION defined.
  13.         Print();
  14.     }
  15.  
  16.     [Conditional("ENABLE_FUNCTION")]
  17.     public static void Print()
  18.     {
  19.         Console.WriteLine("Print when ENABLE_FUNCTION defined.");
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement