by Mikael Henriksson
17. February 2009 21:15
I am as I have posted before lazy. I am also very hesitant to using extension methods. There is nothing wrong with this but they pop up everywhere eventually. I did however create an extremely useful extension method for something as simple as getting the name of a specified dates month. This is displayed based on the current culture.
It is only one line of code but it’s one hell of a line to remember and that’s why I created the extension for it! :)
using System.Threading;
public static string MonthName(this DateTime date)
{
return Thread
.CurrentThread
.CurrentCulture
.DateTimeFormat
.MonthNames[date.Month];
}
b0a35dc5-021e-4a60-8ad1-0c85564dd415|0|.0
Tags: C#
C#