C# Unit Testing in a nutshell

OK so there’s a thing called test-based development techniques. Essentially it means that if you want to write a piece of code, you first write a test piece which defines an example of input variables and corresponding output varaibles. It then calls the function you want to write and retrieves the ouput from that function. …

C# Write to File

Writing to a file is relatively easy in C#. ///<summary> ///Write an entry to our logfile</summary> ///<param name=”message”>The message you want to write to the log file</param> private voidlog(string message) { StreamWriter writer = newStreamWriter(@”c:\log.txt”, true); writer.WriteLine(formatEntry(message)); writer.Flush(); writer.Close(); } Simple.

C# background processing

Here’s a quick reminder on how to not tie up you form thread while doing time consuming operations from controls on a form. .NET makes this relatively easy: 1. Declare your delegate: private delegate void CallAsyncWorkerDirectDelegate(string func, string param); 2. Write your Worker function private void CallAsyncWorkerDirect(string func, string param) { string parm1, parm2; parm1 …

Happy to be a Contractor

Code. To me this is the essence what I do on a daily basis. I’ve been doing for about 6 years, roughly 10 hours a day. Surprisingly I still like it. And probably will for a long time. But don’t you think sometimes all code is just the same thing? If you think back to …