The C# equivalent would be to define
WindowsForms and then to do this:
#if WindowsForms
#endif
You can define a symbol either via
#define
or via the project settings.
Example of doing it in code:
#define WindowsForms
[Edit]
~~~~~~~~~~
The
#define
has to come before any other tokens in the source file. Example:
#define WindowsForms
using System;
namespace Nothing
{
class Program
{
static void Main(string[] args)
{
#if WindowsForms
Console.WriteLine("WindowsForms defined");
#else
Console.WriteLine("WindowsForms not defined");
#endif
}
}
}
Basically the
#if
check checks to see if the symbol is defined. It cannot check for a value. It only checks for definition.