You probably are after something like this:
if(System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break();
Of course that will still get compiled in a Release build. If you want it to behave more like the Debug object where the code simply doesn’t exist in a Release build, then you could do something like this:
// Conditional("Debug") means that calls to DebugBreak will only be
// compiled when Debug is defined. DebugBreak will still be compiled
// even in release mode, but the #if eliminates the code within it.
// DebuggerHidden is so that, when the break happens, the call stack
// is at the caller rather than inside of DebugBreak.
[DebuggerHidden]
[Conditional("DEBUG")]
void DebugBreak()
{
if(System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break();
}
Then add a call to it in your code.