GetType in static method [duplicate]

Solution 1:

The "type" within a static method is always the specific type, since there is no such thing as a virtual static method.

In your case, this means you can just write:

 var myActualType = typeof(MyBase);

Since the "type" of MyMethod, being a static, is always a static method of MyBase.

Solution 2:

What about this?

abstract class MyBase<T>
{
   public static void MyMethod()
   {
      var myActualType = typeof(T);
      doSomethingWith(myActualType);
   }
}


class MyImplementation : MyBase<MyImplementation>
{
    // stuff
}

Solution 3:

This is the pattern i used.

abstract class MyBase
{
   public static void MyMethod(Type type)
   {
      doSomethingWith(type);
   }
}