As someone who comes from C ++ background, I came across the following situation:
Given that C # does not support typedefs, how do you programmatically bind types. That is, in C ++, I can store related types as typedefs for retrieval when used with templates. The same cannot be done in C # in the same way due to a lack typedef.
For example, in C ++ I would:
template< typename T >
class Thing : public ThingBase<T>
{
public:
bool isRelated( T::Parent & otherThing )
{
T::Auxillary aux( "Yes" );
return aux.isValid( otherThing ) && data.isParent( otherThing );
}
private:
T data;
};
This will work with any of the following methods:
class SomeClass
{
public:
typedef SomeClassParent Parent;
typedef FooAuxillary Auxillary;
bool isParent( Parent & parentObject );
};
class OtherClass
{
public:
typedef OtherClassParent Parent;
typedef BarAuxillary Auxillary;
bool isParent( Parent & parentObject );
};
Although the ability to call T::isParentby parameter type can be achieved using a common interface interface, creating a signature for Thing::isRelatedit seems impossible without typedefs.
So, in C #, what should I do to get the associated interface type for T (which is T :: Interface in the C ++ example)?