What I want to achieve is this:
to give an incorrect example:
public class MyClass<T> : MyParentClass where T : IMySpecialInterface<X>
{
...
}
What is the proper syntax to achieve this?
Thanks.
In C you do not have the this keyword. Only in C++ and in a class, so your code is C and you use your this variable as a local method parameter, where you access the array struct.
In C++ programming, this is a keyword that refers to the current instance of the class. There can be 3 main usage of this keyword in C++. It can be used to pass current object as a parameter to another method. It can be used to refer current class instance variable.
Auto is a storage class/ keyword in C Programming language which is used to declare a local variable. A local variable is a variable which is accessed only within a function, memory is allocated to the variable automatically on entering the function and is freed on leaving the function.
You can't use generics without knowing the types, unless you created the type at runtime.
Your best fit would be:
public class MyClass<T, U> : MyParentClass where T: IMySpecialInterface<U>
{
}
UPDATE or could you potentially use dynamic
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With