http://msdn.microsoft.com/en-us/library/4y6tbswk.aspx
When the C# compiler encounters an #if directive, followed eventually by an #endif directive, it will compile the code between the directives only if the specified symbol is defined. Unlike C and C++, you cannot assign a numeric value to a symbol; the #if statement in C# is Boolean and only tests whether the symbol has been defined or not. For example,
#define DEBUG // ... #if DEBUG Console.WriteLine("Debug version"); #endif
You can use the operators == (equality), != (inequality) only to test for true or false . True means the symbol is defined. The statement #if DEBUG has the same meaning as #if (DEBUG == true). The operators && (and), and || (or) can be used to evaluate whether multiple symbols have been defined. You can also group symbols and operators with parentheses.
OR
namespace Mvc3RemoteVal.Controllers
{
public class HomeController : Controller
{
IUserDB _repository;
#if InMemDB
public HomeController() : this(InMemoryDB.Instance) { }
#else
public HomeController() : this(new EF_UserRepository()) { }
#endif
public HomeController(IUserDB repository)
{
_repository = repository;
}
[...]
}
