I have the following:
public static class CityStatusExt { public static string D2(this CityStatus key) { return ((int) key).ToString(\"D2\");
You can make the method generic. C# will infer the type:
public static class Extension { public static string D2 (this T key) { return ((int)(object) key).ToString("D2"); } }