Everything you ever wanted to know about an enum (well, almost everything)

The enum, what a lovely creature available to us in C#. They help make our code more readable and bug-resistant. They also have some tricks up their sleeves.
Take a sample enum declaration:

public enum Level
{
Unknown = 0,
Low,
Medium,
High
}

If you want a string representation of an enum, you simply use the ToString() method.

Console.WriteLine(Level.Unknown.ToString());
/* output:
Unknown
*/

If you want the numeric [...]

Popularity: 8% [?]

C# 3.0’s syntatic sugar

In the old days, we’d write something like this:

view.Rows.Add("Type");
view.Rows.Add("Count");
view.Rows.Add("Whatever");

With C# 3.0 we can do this:

new string[] { "Type", "Count", "Whatever" }
.ForEach(str => view.Rows.Add(str));

That is very cool syntatic sugar. Sure, this is not new news, but when you think about C# in the context of the new features available in 3.0, it [...]

Popularity: 8% [?]

Google AdSense ViewComponent for MonoRail

Like many, I use Google AdSense to host ads on my web sites. Including the ad code typically requires you to paste a block a block of JavaScript onto the page. I don’t mind injecting the JavaScript, but I wanted to come up with a better way.
The solution I came up with was a quick [...]

Popularity: 14% [?]