Type Names
I picked up a lot of interesting knowledge about C# in the course of developing and testing a parser for the language. I'll try to post a few tidbits as they come to mind again.
One nice tidbit is how to create new short type names without having to specify the full name of every non-primitive type, especially inside of generic type names.
Normally, using "using" to create a new type name, even in the presence of the appropriate namespace import, one has to fully qualify every type name that is not a keyword.
using System.Collections.Generic; using T = System.Collections.Generic.List<string>
However, if the "using" is inside a namespace, then it will utilize any imports located in an outer namespace.
using System.Collections.Generic; namespace MyCompany { using T = List<string>; }
Funny one!
Posted by: Olivier | October 24, 2007 at 12:10 PM
Doesn't this also change the effective scoping of the alias?
Posted by: Greg D | October 24, 2007 at 01:22 PM