Solved

Access type parameters of generic type

Posted on 2011-02-21
4
212 Views
Last Modified: 2013-12-17
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
0
Comment
Question by:bovlk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34943253
>>  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

0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 34943262
Crap....   I have that backwards  : \
using MyXYZCollection = MyCollection<TX, TY, TZ>;

Open in new window

0
 

Author Comment

by:bovlk
ID: 34952399
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?
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 500 total points
ID: 34956354
Not that I know of.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question