Türkçe   |   English
Calendar
Categories
Archive
Links
Blogroll
Files

18.09.2009
#if DEBUG and [Conditional("DEBUG")]

If we want a code block to run in only debug mode, we can use one of these 2 ways:

  private void Form1_Load(object sender, EventArgs e)
        {

#if DEBUG
            MessageBox.Show("debug");
#else
                MessageBox.Show("not debug");
#endif
            RunInDebug();
        }

        [Conditional("DEBUG")]
        static void RunInDebug()
        {
            MessageBox.Show("Debug mode");
        }

Code
Comments(0)

Photos
Me in MSDN Forums
Entries
News
Articles