Assert
| Visual C# Tutorials |
| Visual C# .NET Tutorials |
| Testing and Debugging |
| edit |
Assert is perfect if you want to be informed via a message box if something doesn’t meet your expectations.
Contents |
[edit]
Example
using System; using System.Windows.Forms; using System.Diagnostics; namespace debugTesting { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void pass_Click(object sender, EventArgs e) { int tempValue = 42; Debug.Assert(tempValue > 0); MessageBox.Show("I got here... Just as I should.. No Error"); } private void fail_Click(object sender, EventArgs e) { int tempValue = -42; Debug.Assert(tempValue > 0); MessageBox.Show("If I get here...Well.. Something's not right"); } } }
[edit]
Result in Development Mode
[edit]
Result from Debug Build
[edit]


