<p>I would like to enable/disable some code based on a custom solution configuration I added in Visual Studio.  How do I check this value at runtime?</p>

[{'answer_id': 31503, 'author': 'Kibbee', 'author_id': 1862, 'author_profile': 'https://Stackoverflow.com/users/1862', 'pm_score': 0, 'selected': False, 'text': "<p>I'm not sure if you can figure out the exact name of the build configuration.  Howerver, if you use Debug.Assert(...), that code will only be run when you compile in debug mode.  Not sure it that helps you at all.</p>\n"}, {'answer_id': 31505, 'author': 'Jon Limjap', 'author_id': 372, 'author_profile': 'https://Stackoverflow.com/users/372', 'pm_score': 4, 'selected': True, 'text': '<p>You can use <a href="http://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx" rel="noreferrer">precompiler directives</a> within Visual Studio. The #if directive will allow you to determine if you are going to include code or not based on your custom solution configuration.</p>\n'}, {'answer_id': 31507, 'author': 'CiNN', 'author_id': 2566, 'author_profile': 'https://Stackoverflow.com/users/2566', 'pm_score': 3, 'selected': False, 'text': '<p>add a const value assign to a value that designate the configuration you are in.\nlike</p>\n\n<pre><code>#ifdef _ENABLE_CODE1_\nconst codeconfig = 1;\n#else\nconst codeconfig = 2;\n#endif\n</code></pre>\n\n<p>and add _ENABLE_CODE1_ in your configuration preprocessor.</p>\n'}, {'answer_id': 31547, 'author': 'Luke', 'author_id': 327, 'author_profile': 'https://Stackoverflow.com/users/327', 'pm_score': 2, 'selected': False, 'text': "<p>In each project's properties under the build section you can set different custom constants for each solution configuration.  This is where you define custom pre-compiler directives.</p>\n"}]
['https://Stackoverflow.com/questions/31496', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/327/']