Ok, I know from documentation (from here and here) how to write simple generic classes with generic methods. But in my case I have something different and I'm not sure what is the right way to implement this. So this is what I have in semi pseudo-code
// This is a base class
public class Parent_Class<T>{
T field_1;
public void method_1<T2>(){
T2 local_variable = new T2();
}
}
// ^^^ Is it right?? And is it possible to inherit from this class in this way (option 1):
public Child_Class : Parent_Class <Class_1>{
public void method_1(){
base.method_1<Class_2>();
// ^^^ will this work???
}
}
And I see another alternative which may look in semi pseudo-code like this:
// This is a base class
public class Parent_Class<T, T2>{
T field_1;
public void method_1<T2>(){
T2 local_variable = new T2();
}
// ^^^ should it be declared like public void method_1<T2>
// or can we simply declare it with public void method_1(){
}
// ^^^ Is it right?? And is it possible to inherit from this class in this way (option 1):
public Child_Class : Parent_Class <Class_1, Class_2>{
public void method_1(){
base.method_1<Class_2>();
// ^^^ should I call it like this? or can I do simply
//base.method_1();
}
}
So, as you can see there is a mixture of generic types. I put my questions in the code and hope someone can point me to the right direction. Thanks!