Link to home
Start Free TrialLog in
Avatar of bovlk
bovlk

asked on

Access type parameters of generic type

Hello,

suppose I have a generic type MyCollection<TX, TY, TZ> in C# 3.5. Now, I want to use as a type parameter in another generic type which needs just one type param, e.g. OtherTYpe<TA> where TA:MyCollection. How can I refer to TA.TX, TA.TY, TA.TZ inside the template of OtherTYpe? I dislike the idea of declaring OtherType<TA, TX, TY, TZ> when TX, TY, TZ are already present in TA.

Also, is there something like the C typedef keyword, so that I can easily name MyCollection<TX, TY, TZ> as MyXYZCollection without having to create a descendant type? I.e.
typedef MyCollection<TX, TY, TZ> MyXYZCollection

Thanks in advance
Avatar of kaufmed
kaufmed
Flag of United States of America image

>>  Also, is there something like the C typedef keyword, so that I can easily name MyCollection<TX, TY, TZ> as MyXYZCollection
using MyCollection<TX, TY, TZ> = MyXYZCollection;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bovlk
bovlk

ASKER

Thanks, kaufmed. It's a very helpful solution. However, it's not exactly what I wanted since this is valid just inside the file in which it is declared. The C/C++ typedef is valid in any file into which I include that header. So is there any way to create a global alias valid throughout an entire ASP.NET application?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial