Wednesday, 18 April 2012

Debugger Tricks

DebuggerDisplay Attribute

image

DebuggerHidden Attribute

If you Step-Into line 10 the debugger will ignore your request and step over.  Useful for preventing tedious code debugging steps.

using System.Diagnostics;

namespace DebuggerTricks
{
class Program
{
static void Main(string[] args)
{
var calculator = new Calculator(1, 2);
var result = calculator.Add();
}

public class Calculator
{
public int a { get; set; }
public int b { get; set; }

public Calculator(int a, int b)
{
this.a = a;
this.b = b;
}

[DebuggerHidden]
public int Add()
{
return a + b;
}
}
}
}

No comments:

Post a Comment