Alex Rivera | Logout

What is the use of #if in C#?

Asked 2010-06-07T12:09:14.910
15

I need to know the usage of #if in C#...Thanks..

Edit
Report

2 Answers

4

#if has lost so much compared to its ancestors -- c or C++. nowadays I use #if for only two scenarios

1) use it to enable code for debug or not debug

#if DEBUG
    // code inside this block will run in debug mode.
#endif

2) use it to quickly turn off code

#if false
     // all the code inside here are turned off..
#endi
answered 2010-06-07T13:04:26.000
2

#if (C# Reference) is a compiler directive. See the MSDN article for more info.

answered 2010-06-07T12:12:00.730

Your Answer