C#: My First Extension Method
I will find many, many uses for this ... maybe someone else will too!
using System;
using System.Diagnostics;
internal static class StringExtensions
{
public static T ToEnum<T>(this string value)
where T : struct
{
Debug.Assert(!string.IsNullOrEmpty(value));
return (T)Enum.Parse(typeof(T), value, true);
}
}