r/csharp • u/Alert-Neck7679 • 17m ago
Help What happens to the expression that is passed to Debug.Assert() on Release?
If I understand it correctly, when you write Debug.Assert(value) it's only included if debug mode is enabled, but not when it's release mode.
So, what happens if I pass an expression as the argument to this method? Let's say it's a function call, would it be executed on release mode? Or should this:
Debug.Assert(ImportantFuncWhichReturnsBool());
Become this:
bool value = ImportantFuncWhichReturnsBool();
Debug.Assert(value);
Thanks in advance