How do you give a namespace an alias in C #

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

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

so i can do it

Station.Object obj = new ...

instead

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

+3
source share
4 answers

You can specify a namespace alias in the using statement.

using Station = Foo.Bar.Space.Station.Bar;
+14
source
using Station = Foo.Bar.Space.Station.Bar;

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

+3
source
using Foo.Bar.Space.Station.Bar = Station;
-4
source

Source: https://habr.com/ru/post/1713892/


All Articles