tags:

views:

131

answers:

4

I have a large namespace: Foo.Bar.Space.Station.Bar and I was to alias is as something shorter like, Station. How do I do that in the using section?

using Foo.Bar.Space.Station.Bar Object ???

so I can do this

Station.Object obj = new ...

instead of

Foo.Bar.Space.Station.Bar.Object obj = new ...

+6  A: 

You can give an alias to a namespace in a using statement.

using Station = Foo.Bar.Space.Station.Bar;
Jake Pearson
A: 
using Foo.Bar.Space.Station.Bar = Station;
MartinHN
please correct your reply.
Syed Tayyab Ali
+1  A: 
using Station = Foo.Bar.Space.Station.Bar;

But in my opinion, having two namespaces named Bar is not a very good idea. :) Even if it's not real code.

ShdNx
+1  A: 

Check out http://www.blackwasp.co.uk/NamespaceAliasQualifier.aspx as it will explain it as well as some problems that could arise. Look especially at the section about namespace alias qualifiers.

CLR