Я думаю, что то, чего я желаю, невозможно, однако я попробую.
У меня есть статический класс, у которого есть этот метод:
Код: Выделить всё
public static class BaseTypeID
{
static ulong _id = 1;
public static ulong NextID => _id++;
}
public static class TypeID where T : class
{
public static readonly ulong ID = 0;
static TypeID()
{
ID = BaseTypeID.NextID;
}
}
public static class Register
{
public static void PrintType(T passedVar) where T : AbstractType
{
Console.WriteLine(TypeID.ID);
}
}
Код: Выделить всё
public abstract class AbstractType
{
public void UseStaticMethod() => Register.PrintType(this);
}
Код: Выделить всё
public class InheritingType : AbstractClass { }
Код: Выделить всё
InheritingType myVar = new InheritingType();
myVar.UseStaticMethod();
Большое спасибо
Подробнее здесь: https://stackoverflow.com/questions/791 ... iting-type