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

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

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

Add Comment
First Name Last Name
Web Site
E-Mail
Comment

Photos
Me in MSDN Forums
Entries
News
Articles