Conditional Compilation If Else Format C# with Example



Conditional Compilation If Else Format C# with Example

 	#define PRODUCTION
	#define TRIAL
	
	using System;

	namespace CSharpPreprocessor
	{
		class ConditionalCompilation
		{
			static void Main()
			{
				#if EXPERIMENTAL
					Console.WriteLine("Compiled for experimental version.");
				#else
					Console.WriteLine("Compiled for release.");
				#endif
				
				#if EXPERIMENTAL && TRIAL
					Console.Error.WriteLine("Testing experimental trial version.");
				#else
					Console.Error.WriteLine("Not experimental trial version.");
				#endif
				
				Console.WriteLine("This is in all versions.");
			}
		}
	} 

0 Comment's

Comment Form

Submit Comment