Define contant and use it in Conditional attribute : Attribute : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Attribute »

 

Define contant and use it in Conditional attribute








    
 

#define LOG

using System;
using System.IO;
using System.Diagnostics;


class Starter {
    static void Main() {
        LogInfo(new StreamWriter(@"c:\logfile.txt"));
    }

    [Conditional("LOG")]
    private static void LogInfo(StreamWriter sr) {
        // write information to log file
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Attribute