You can use the using directive to create an alias for a namespace, which you can then use to access the types in that namespace. For example:
1
2
| using U1 = DogLibrary.Utility.StandardLogging;using U2 = DogLibrary.Utility.AlternateLogging; |
We might do the above if we had an identically named type in each of the two namespaces so that we could then prefix the type with the appropriate namespace.
1
2
| U1.DogLogger log1 = new U1.DogLogger(@"C:\log1.txt");U2.DogLogger log2 = new U2.DogLogger(@"C:\log2.txt"); |
We can also use the using directive to create an alias for a specific type. For the example above, we could do the following:
1
2
| using Logger1 = DogLibrary.Utility.StandardLogging.DogLogger;using Logger2 = DogLibrary.Utility.AlternateLogging.DogLogger; |
We could then use the alias directly as a type name:
1
2
3
4
5
| // Short for DogLibrary.Utility.StandardLogging.DogLoggerLogger1 log1 = new Logger1(@"C:\log1.txt");// Short for DogLibrary.Utility.AlternateLogging.DogLoggerLogger2 log2 = new Logger2(@"C:\log2.txt"); |

