Groups | Blog | Home
all groups > c# > june 2005 >

c# : Long Generic Instantiations


Jay B. Harlow [MVP - Outlook]
6/21/2005 3:13:06 PM
Jasper,
Have you considered inheritance?

As the import alias is nothing more then an alias that is local to that
source file.

Something like (not tested):

class InnerDictionary : System.Collections.Generic.Dictionary<int,
string>
{ }

class BigDictionary :
System.Collections.Generic.Dictionary<int,InnerDictionary>
{ }

Hope this helps
Jay


[quoted text, click to view]
| I'm trying to do the equivalent of using typedefs with templates in C++ to
| avoid long instantiation names.
|
| I can do this okay:
|
| using BigDictionary = System.Collections.Generic.Dictionary<int,
| System.Collections.Generic.Dictionary<int, string>>;
|
| class MyClass
| {
| private BigDictionary myDictionary;
| }
|
| But I think it would be tidier to break it down, something like:
|
| using InnerDictionary = System.Collections.Generic.Dictionary<int,
string>;
| using BigDictionary =
| System.Collections.Generic.Dictionary<int,InnerDictionary>;
|
| class MyClass
| {
| private BigDictionary myDictionary;
| }
|
| However, InnerDictionary is not recognised in the declaration of
| BigDictionary. Is there any way I can do this?
|
| In practice, the types I am using are fully scoped, rather than being
| fundamental types, so the whole thing is even more verbose.
|
| Thank is advance.
|
|

Nicholas Paldino [.NET/C# MVP]
6/21/2005 4:08:15 PM
Jasper,

Unfortunately, there is no way to do this. The using statement doesn't
allow references to other using statements, so you will have to create
separate aliases for each.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

Jasper Kent
6/21/2005 7:38:45 PM
I'm trying to do the equivalent of using typedefs with templates in C++ to
avoid long instantiation names.

I can do this okay:

using BigDictionary = System.Collections.Generic.Dictionary<int,
System.Collections.Generic.Dictionary<int, string>>;

class MyClass
{
private BigDictionary myDictionary;
}

But I think it would be tidier to break it down, something like:

using InnerDictionary = System.Collections.Generic.Dictionary<int, string>;
using BigDictionary =
System.Collections.Generic.Dictionary<int,InnerDictionary>;

class MyClass
{
private BigDictionary myDictionary;
}

However, InnerDictionary is not recognised in the declaration of
BigDictionary. Is there any way I can do this?

In practice, the types I am using are fully scoped, rather than being
fundamental types, so the whole thing is even more verbose.

Thank is advance.

AddThis Social Bookmark Button