如何获得命名空间别名操作符::在C#的工作? [英] How to get the namespace alias operator :: to work under C#?

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

问题描述

我碰到的情况不太可能发生,当我引用两个外部组件,这两个具有相同的命名空间和类型名称。当我尝试使用类型,编译器会引发一个错误,它不能解决我想用哪一个。

我看到C#提供了使用别名引用的机制。你甚至可以通过在Visual Studio 2008中引用我的code我如何使用这个别名的属性窗口中指定这些别名?据我了解,我应该使用 :: 运营商,但它失败,出现以下错误:

  

CS0432 - 别名找不到

通常的经营者不也是如此。

在输出窗口,我看到,编译器获取其命令行传递正确的别名。

在我或许可以尝试下任何指针都大大AP preciated。

解决方案

 外部别名alias1;
使用alias1 ::命名空间;
 

I've come up against the unlikely scenario when I reference two external assemblies that both have the same namespace and type names. When I try to use the type, the compiler throws an error that it cannot resolve which one I want to use.

I see that C# offers a mechanism to use aliases for references. You can even specify these aliases via the Property window of a reference in Visual Studio 2008. How do I use this alias in my code? As I understand, I should be using the :: operator, but it fails with the following error:

CS0432 - Alias not found

The usual . operator fails as well.

In the output window I see that the compiler gets the alias passed correctly in its command line.

Any pointers on what I may be able to try next are greatly appreciated.

解决方案

extern alias alias1;
using alias1::Namespace;

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

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