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
Security Picture

Photos

Lighthouse
Show All
Me in MSDN Forums
-   Answered the question How can i get it in the Visual C# General forum
-   Answered the question How to add the VAT to the ammount in the Visual Basic General forum
-   Contributed a proposed answer to the question How to add the VAT to the ammount in the Visual Basic General forum
-   Replied to the question How can i get it in the Visual C# General forum
-   Replied to the question How to add the VAT to the ammount in the Visual Basic General forum
-   Answered the question How to show ToolStripMenuItem's hot key? in the Windows Forms General forum
-   Contributed a proposed answer to the question How to show ToolStripMenuItem's hot key? in the Windows Forms General forum
-   Answered the question Expert to Excel Missing Some Data In Grid View in the Visual C# Language forum
-   Contributed a helpful post (total votes:1) to the forums thread Expert to Excel Missing Some Data In Grid View in the Visual C# Language forum
-   Replied to the question How to show ToolStripMenuItem's hot key? in the Windows Forms General forum
Entries
News
Articles