M
MMAS
Hey Everyone
I know that I can do something like this in C#
MyClass<WHATEVER>
{
private WHATEVER var_name_of_type_whatever;
public ChangeVar(WHATEVER change_to_value)
{
var_name_of_type_whatever = change_to_value;
}
}
But is there a way to do this?
MyClass<WHATEVER:RealInterfaceClass>
{
private WHATEVER
var_name_of_type_whatever_that_is_forced_to_be_of_basetype_RealInterfaceClass;
public CallMethodThatExistsOnRealInterfaceClass()
{
var_name_of_type_whatever_that_is_forced_to_be_of_basetype_RealInterfaceClass.MethodIKnowExists();
}
}
so that in my templated code I can treat that variable as a
RealInterfaceClass and call its methods?
I'm just curious if something like this is possible, instead of just
having the variable be of type RealInterfaceClass and having to upcast
it to the derived class when I'm using the object.
Thanks
Mustafa
I know that I can do something like this in C#
MyClass<WHATEVER>
{
private WHATEVER var_name_of_type_whatever;
public ChangeVar(WHATEVER change_to_value)
{
var_name_of_type_whatever = change_to_value;
}
}
But is there a way to do this?
MyClass<WHATEVER:RealInterfaceClass>
{
private WHATEVER
var_name_of_type_whatever_that_is_forced_to_be_of_basetype_RealInterfaceClass;
public CallMethodThatExistsOnRealInterfaceClass()
{
var_name_of_type_whatever_that_is_forced_to_be_of_basetype_RealInterfaceClass.MethodIKnowExists();
}
}
so that in my templated code I can treat that variable as a
RealInterfaceClass and call its methods?
I'm just curious if something like this is possible, instead of just
having the variable be of type RealInterfaceClass and having to upcast
it to the derived class when I'm using the object.
Thanks
Mustafa