title: How to use #if to decide which platform is being compiled for in C#
body: <p>In C++ there are predefined macros:</p>
  <pre><code>#if defined(_M_X64) || defined(__amd64__)
      // Building for 64bit target
      const unsigned long MaxGulpSize = 1048576 * 128;// megabyte = 1048576;
      const unsigned long MaxRecsCopy = 1048576 * 16;
  #else
      const unsigned long MaxGulpSize = 1048576 * 8;// megabyte = 1048576;
      const unsigned long MaxRecsCopy = 1048576;
  #endif
  </code></pre>
  <p>Which allows me to set constants to control the amount of memory that will be used.</p>
  <p>Of course I can define a preprocessor variable verbatim:</p>
  <pre><code>#define Is64bit 1
  
  using System;
  using System.Collections.Generic;
  </code></pre>
  <p>-later-</p>
  <pre><code>#if Is64bit
      // Building for 64bit target
      const long MaxGulpSize = 1048576 * 128;// megabyte = 1048576;
      const long MaxRecsCopy = 1048576 * 16;
  #else
      const long MaxGulpSize = 1048576 * 8;// megabyte = 1048576;
      const long MaxRecsCopy = 1048576;
  #endif
  </code></pre>
  <p>I cannot find a way to detect the platform based on the values set in the configuration manager which would allow for command line building:</p>
  <pre><code>set de=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
  set sol=E:\Some\Path\to\my.sln
  &quot;%de%&quot; %sol% /build &quot;Release|x86&quot;
  &quot;%de%&quot; %sol% /build &quot;Release|x64&quot;
  </code></pre>
  <p>Is there a way to detect this or will I have to build, change platform and build again?</p>
  <p>Update: The 32/64 bit question became a moot point when the last of the 32bit Windows 7 workstations were retired so needing to compile for both platforms was no longer necessary. I think though it's worthwhile to retain this thread as the concepts can help with other preprocessor directives, targeting MS Office vs Open Office for example.</p>