MintyAnt
MintyAnt

Reputation: 3058

Block out certain code in distribution or editor builds, like #if defined

In the application I am creating, I am hooking an "Editor" up directly to the app. However, the editor acts as an external program, poking at the app.

Some of the accessors and mutators the editor will use will most definitely not be used in the app itself, and shouldn't ever be used!

Since I work on a team, I want to "Block Out" certain function and classes entirely when running in non-editor builds.

In C++, I could do something like this:

#if !defined(_DISTRIBUTION)
    void SetUniqueID(int inID) { mID = inID; }
#endif

When the above code is used in debug or editor builds, it is called fine. When used in release builds, the compiler or game will fail.

What is the C# equivalent to this?

Upvotes: 1

Views: 95

Answers (2)

david.s
david.s

Reputation: 11403

#if DEBUG
    Console.WriteLine("Mode=Debug"); 
#else
    Console.WriteLine("Mode=Release"); 
#endif

Upvotes: 1

Sam Axe
Sam Axe

Reputation: 33738

These are conditional compilation directives.

Upvotes: 3

Related Questions