Solved

Access type parameters of generic type

Posted on 2011-02-21
4
210 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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