document updated 16 years ago, on Mar 6, 2008
- custom compile-time errors
#error I noticed a runtime bug here. If you try to run this again, this will certainly fail.
or
#warning I should probably fix this soon.
- custom runtime errors:
using System.Diagnostics;
Debug.Assert(1==2);
or
Debug.Fail("If we get to here, fail always");
- for informal debug logging, use one of these:
Console.WriteLine("var1 = {0}, var2 = {1}", var1, var2);
MessageBox.Show("hello world");
or, to only output to the
System.Diagnostics.Debug.WriteLine("hello world");
TODO: what's the equivalent of Perl's Data::Dumper::Dump()? (OTHER than .ToString())
- To update forms from a different thread... there are many ways, but the only way to use is this:
http://google.com/search?q=%22Invoke%28%28MethodInvoker%29delegate%22
(note: the above requires understanding closures first: http://www.thinkingms.com/pensieve/CommentView,guid,9fe42970-09e3-44e2-a4d0-32d63139351a.aspx)