Archive for the '.NET' Category

log4net Slides and Example Code

I have been contacted people who cannot attend my Toronto Code Camp session on log4net tomorrow requesting a copy of my presentation and example code. I cannot find it posted on the Code Camp site, so here is a copy for anyone who is interested.
The presentation is in PowerPoint 2007 and the example code [...]

Speaking at Toronto Code Camp

I found out last week that I will be speaking at this year’s Toronto Code Camp on March 1st.  I will be giving an Introduction to log4net from 9:00 AM to 10:15 AM.
I will begin the session with an overview of the license, features and capabilities of log4net, including log levels, log hierarchies, logging [...]

The Stopwatch Class in .NET

Do you ever find yourself using DateTime to time a section of code?  Do you have code like the following?
DateTime start = DateTime.Now;

// Perform a long process
Thread.Sleep( 1968 );

DateTime end = DateTime.Now;
TimeSpan duration = end.Subtract( start );
Console.WriteLine( “This process took {0} ms”,
[...]

Writing An Appender For log4net

In log4net speak, an appender is an output destination for a log such as a file, the console, a database or even email.  log4net ships with so many appenders that most of us will never need to write our own.  There are cases where you may find a need for your own appender, for example, [...]

Debugging C++ Method Parameters

New Rule: Make sure your parameter names are consistent between your declarations and definitions in C++.
Here is why…
I was trying to debug some C++/CLR code today when I ran into an interesting behavior (bug?) in Visual Studio 2005. I had a breakpoint in the first line of my method which I hit fine. I then [...]

Easier Debugging with Attributes

Unless you have been inspecting some of the code generated by Visual Studio, you probably haven’t realized that there are several attributes that you can add to your code to make debugging easier. Some prevent you from stepping into sections of code, others change the way variables are displayed in the watch window.
The following [...]

Win32 COLORREF vs .NET Color

I have been migrating a large application from Win32/MFC to .NET and ran into an interesting problem. We store all of the application colors in the database as integers that represent the Win32 COLORREF value. COLORREF is just a DWORD representing the RGB value, so I thought that I could just take the value and get a .NET [...]

The Yield Statement in C#

Another often overlooked C# statement that was introduced in .NET 2.0 is yield. This keyword is used to return items from a loop within a method and retain the state of the method through multiple calls. That is a bit hard to wrap your head around, so as always, an example will help;
public static IEnumerable<int> [...]

Null Coalescing Operator

The first time I saw the ?? operator in C#, I did a double take and had to look it up. The operator, called the null coalescing operator was added in C# 2.0 and is pretty useful, but still fairly unknown.

Order order = GetOrder( id ) ?? new Order();
In the above code, if the return [...]

.NET Podcasts

The landscape of software development changes quickly and it is hard for developers to keep up. During my commute to and from work, I listen to a selection of podcasts that help me keep up with new technologies and where .NET development is going. They expose me to new technologies coming out of Microsoft, [...]