Nested Aliases in C #

I saw a lot of answers to the typedef problem in C # that I used, so I have:

 using Foo = System.Collections.Generic.Queue<Bar>; 

and it works well. I can change the definition (esp. Change Bar => Zoo, etc.) and everything that uses Foo changes. Fine.

Now I want this to work:

 using Foo = System.Collections.Generic.Queue<Bar>; using FooMap = System.Collections.Generic.Dictionary<char, Foo>; 

but C # doesn’t look like Foo in the second line, although I defined it in the first.

Is there a way to use an existing alias as part of another?

Edit: I am using VS2008

+6
c # alias typedef
source share
1 answer

According to the standard, it looks like the answer is no. From Section 16.3.1 , Clause 6:

1 The order in which using-alias directives is written does not affect any value and the name-space-type-name referenced using the-alias directive is not affected by the alias instruction itself or other control directives in the unit immediately containing the compilation or namespace.

2 In other words, the name of a namespace or type using the-alias directive is resolved as if the compilation unit or body of the namespace is immediately without using directives.

Edit:

I just noticed that the version on the above link is a bit outdated. The text from the corresponding paragraph in 4th Edition is more detailed, but still prohibits reference to the use of aliases within others. It also contains an example that makes this explicit.

Depending on your reach and typing needs, you might want to get away with something like:

 class Foo : System.Collections.Generic.Queue<Bar> { } 
+13
source share

All Articles