Preprocessor directives in C#

By: Ram Baskar Viewed: 161 times  Printer Friendly Format    


C# features "preprocessor directives" (though it does not have an actual preprocessor) based on the C preprocessor that allow programmers to define symbols but not macros. Conditionals such as #if, #endif, and #else are also provided. Directives such as #region give hints to editors for code folding.

public class Foo
{
    #region Procedures
    public void IntBar(int firstParam) {} 
    public void StrBar(string firstParam) {} 
    public void BoolBar(bool firstParam) {} 
    #endregion

    #region Constructors
    public Foo() {}
    public Foo(int firstParam) {}
    #endregion

}


Most Viewed Articles (in Csharp )

Latest Articles (in Csharp)

Comment on this tutorial