I want to make a method which use generic. This method is implemented from an abstract class. In this method, i cannot use field of the generic type.
So, I have :
public abstract class AbstractClass {
public abstract T Get<T>(T begin) where T: AbstractClass;
}
And the class which implement it:
public class MyClass: AbstractClass {
public int id;
public override MyClass Get<MyClass>(MyClass begin) {
begin.id = 0; // cannot access to "id"
return begin;
}
}
The issue appear in "Get" method implementation. I cannot use MyClass's field or method because it consider it as an AbstractClass object and not MyClass one.
I tried to manually set Get<mypackege.MyClass>
to force it to use the class and access to his content, but i failed.