How to Create Conditional method

Waqas Anwar
29 August 2012

If you want to execute some methods conditionally only in debug mode then you can decorate the method with the Conditional attribute as follows:

First of all import System.Diagnostics namespace
using System.Diagnostics;Then add Conditional attribute to the method you want to execute only in debug mode.
public static void SomeMethod()
   Console.WriteLine("You are in debug mode");