Send mail to the author(s) E-mail

# Wednesday, 25 August 2010
( Debug )

From a SO question:

namespace ConsoleApplication1
class Program
static void Main(string[] args)
Console.WriteLine("Hello world");
string value = SendEmail("");

static string SendEmail(string subject)
#region Parameter assertions
Debug.Assert(subject != "");
return subject;



Put Debug.Assert() everywhere in the code where you want have sanity checks to ensure invariants. When you compile a Release build (i.e., no DEBUG compiler constant), the calls to Debug.Assert() will be removed so they won't affect performance.

You should still throw exceptions before calling Debug.Assert(). The assert just makes sure that everything is as expected while you're still developing.

| | #