Solved

Access type parameters of generic type

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Updating specific fields only in MVC/Entity controller 2 19
asp.net mvc , views, hidden values ? 2 17
reading excel file in .net 2 19
How to repeat the data 4 20
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 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