Fail
From C# Online.NET (CSharp-Online.NET)—your free C# and .NET encyclopedia
| CSharp-Online.NET:Tutorials |
| C# Tutorials |
| Testing and Debugging |
| edit |
When you want to do a 'small/quick test' to see if your code reaches a certian point and you find your self using lines like MessageBox.Show("Got here"); Then replace those for Debug.Fail("Got here"); At least then if you forget about them your Release build won't show them to your end users!
The Debug.Fail method also gives you that bit more information. Not only that, but it allows you to choose there and then if you want to end the program execution, Debug the code, or just ignore it and continue.
[edit]
Example
using System; using System.Windows.Forms; using System.Diagnostics; namespace debugTesting { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void debugFail_Click(object sender, EventArgs e) { int importantVariable = 42; Debug.Fail("Got here"); Debug.Fail("Got here with my importantVariable", importantVariable.ToString()); } } }
[edit]
