别名化/缩短.NET中的命名空间 [英] Aliasing / Shortening the Namespaces in .NET

查看:87
本文介绍了别名化/缩短.NET中的命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个具有Image类的名称空间。一个是 iTextSharp ,另一个是WPF System.Windows.Control.Image

There are two namespaces with class Image. One is iTextSharp and another WPF System.Windows.Control.Image.

现在我必须使用完整的引用,即 System.Windows.Control.Image a = new .. iTextSharp.text。图像b = new ...

Now I've to use complete reference i.e. System.Windows.Control.Image a = new .. and iTextSharp.text.Image b = new ...

是否可以使用别名来命名空间,所以我不必编写完整的命名空间。 / p>

Is there any way to Aliasing the namespace, so I don't have to write complete namespace.

推荐答案

是的,只需使用:

using Img = System.Windows.Control.Image;

在名称空间声明中。

然后您可以像以前使用完全限定名一样使用 Img 别名。

Then you can use the Img aliased name as you used the fully qualified name previously.

这篇关于别名化/缩短.NET中的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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