What are the key uses of a Static Generic Class in C#? When should they be used? What examples best illustrate their usage?
e.g.
One use of static generic classes that I recently learned was possible is to define a constraint on the class level for the type, then the constraint applies to all the static members of the class, what I also learned is that this is not allowed for static generic classes that define extention methods.
For example if you are going to create a static generic class and you know all the generic types should be IComparable (just an example) then you can do the following.
static class MyClass where T : IComparable
{
public static void DoSomething(T a, T b)
{
}
public static void DoSomethingElse(T a, T b)
{
}
}
Notice that I did not need to apply the constraint to all the member, but just at the class level.