如何在C#中为命名空间命名 [英] How do you give a namespace an alias in C#

查看:72
本文介绍了如何在C#中为命名空间命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的命名空间:Foo.Bar.Space.Station.Bar,而我别名就是Station.如何在使用部分中做到这一点?

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?

使用Foo.Bar.Space.Station.Bar对象???

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

所以我可以做到

Station.Object obj =新...

Station.Object obj = new ...

代替

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

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

推荐答案

您可以在using语句中为名称空间指定别名.

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

using Station = Foo.Bar.Space.Station.Bar;

这篇关于如何在C#中为命名空间命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆