JOE SKEET
JOE SKEET

Reputation: 8098

c# a simple debugging question

for (i........)
{
//code
if (specimen == "AA161794") 
   Application.Run();
//more code
}

the if statement is there for debugging purposes. i need to examine some of the variables when specimen is that value. instead of application.run() i just need a generic piece of code to put in there so that it can stop there. it can be something like

messagebox.show("Blah");

what is the correct way of doing this?

Upvotes: 2

Views: 201

Answers (5)

Vijay Sirigiri
Vijay Sirigiri

Reputation: 4711

To use existing constant

 # if DEBUG
            Console.WriteLine("debug mode");
 #  endif

If you define your own constant "Legacy"

 #if Legacy
            Console.WriteLine("legacy mode");
 # endif

enter image description here

Upvotes: 2

SLaks
SLaks

Reputation: 887195

You're trying to make a Conditional Breakpoint.
Right-click the breakpoint and click Condition....

Alternatively, write "".ToString();

Upvotes: 4

dalexsoto
dalexsoto

Reputation: 3412

Setting a Breakpoint in your IDE (visual studio or monodevelop)

here is a nice article of how to setup Conditional breakpoints

http://geekswithblogs.net/sdorman/archive/2009/02/14/visual-studio-2008-debugging-tricks-ndash-advanced-breakpoints.aspx

http://support.microsoft.com/kb/308469

Upvotes: 1

Bernard
Bernard

Reputation: 7961

Use the following: Debug.Assert(false);

Upvotes: 2

Related Questions