Visual-Studio – How to gradually complete the entire code block?

I want to be able to skip certain parts of the code when setting breakpoints. For example, I have a code block that iterates 52 times to create a deck of cards. This is normal work, I would rather not have to press F11 to continue through the block. Do I “skip” this anyway so the debugger can proceed to the next method call?

The language and IDE are C# in VS 2008.

If it is an option, you can move the code into a function and apply the [DebuggerStepThrough] attribute to the function so that it is always skipped during debugging

Like this:

p>

using System.Diagnostics;

namespace MyNamespace
{
public class Utilities
{
[DebuggerStepThrough ]
public ThisIsAVeryLongMethod()
{
//
// Code
//
}
}
}

Now in your code, when you step through it, the debugger will not go to the method, just continue to the next line

ShortMethod1() ;
ThisIsAVeryLongMethod();
ShortMethod2();

I want to be able to skip certain parts of the code when setting breakpoints. For example, I have a code block that iterates 52 times to create a deck of cards. This is normal work, I would rather not have to press F11 to continue through the block. Do I "skip" this anyway so the debugger can proceed to the next method call?

The language and IDE are C# in VS 2008.

If it is an option, you can move the code Into a function and apply the [DebuggerStepThrough] attribute to the function so that it is always skipped during debugging

Like this:

 using System.Diagnostics;

namespace MyNamespace
{
public class Utilities
{
[DebuggerStepThrough]
public ThisIsAVeryLongMethod()
{
//
// Code
//
}
}
}

Now in your code, When you step through, the debugger will not go to that method, but just continue to the next line

ShortMethod1();
ThisIsAVeryLongMethod();
ShortMethod2();

Leave a Comment

Your email address will not be published.