有什么用集引用在Visual Studio 8的别名属性 [英] What use is the Aliases property of assembly references in Visual Studio 8

查看:124
本文介绍了有什么用集引用在Visual Studio 8的别名属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Visual Studio 8中的别名属性添加程序集引用到一个项目,该引用的,被设置为全局。什么是该物业的好,为什么它设置为全局?

When I add an assembly reference to a project in Visual Studio 8 the Aliases property, of that reference, is set to "global". What is this property good for and why is it set to global?

MSDN告诉我,这是别名组件的列表,但不是为什么我可能要使用此属性或为什么大多数都别名为全局。

MSDN tells me that this is a list of aliases for the assembly but not why I might want to use this property or why most are aliased as "global".

参考MSDN

推荐答案

这是外部别名。假设你要使用两种不同类型,这两种被称为 Foo.Bar (即酒吧在一个命名空间)。这两种类型将会在不同的组件(定义) - 使用在VS的财产,以别名与每个参考相关联,那么你可以做:

This is for "extern aliases". Suppose you want to use two different types, both of which are called Foo.Bar (i.e. Bar in a namespace of Foo). The two types will be in different assemblies (by definition) - you use the property in VS to associate an alias with each reference, then you can do:

extern alias FirstAlias;
extern alias SecondAlias;

using FirstBar = FirstAlias::Foo.Bar;
using SecondBar = SecondAlias::Foo.Bar;

然后用 FirstBar SecondBar 在code。

所以基本上它命名的一个额外的水平 - 你不应该使用它,除非你真的不得不这样做。这会迷惑了很多人。尽量避免陷入摆在首位这种情况 - 但要知道这种解决方案对于​​那些时间,你就不能避免它

So basically it's an extra level of naming - and you shouldn't use it unless you really, really have to. It will confuse a lot of people. Try to avoid getting into that situation in the first place - but be aware of this solution for those times where you just can't avoid it.

这篇关于有什么用集引用在Visual Studio 8的别名属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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