Visual Studio中的引用属性中的别名是什么? [英] What is Aliases for in reference properties in Visual Studio?

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

问题描述

在Visual Studio中的C#项目中,展开引用"文件夹.然后查看任何引用的属性.您将在此处看到Aliases属性.在项目中,该属性的值为全局".

In Visual Studio in your C# project expand References folder. Then look at the properties of any reference. You'll see there Aliases property. In project the property has value "global".

有人可以告诉我此属性的用途以及如何使用它吗?

Can someone tell me what this property for and how can I use it?

谢谢.

推荐答案

这是一个猜测.但这与这段代码相同.

This is a guess. But it is same as this piece of code.

using MyNameSpace = MyCompany.MyProject.MyLibrary;

该想法是为了避免名称空间名称冲突.
全局"用于将具有类似名称空间的程序集与框架中的程序分开.

The idea is to avoid namespace name conflict.
"global" is used to separate your assembly having similar namespace from that of the framework.

假设您的库还具有一个控制台类&您的CS文件具有对您的库和mscorlib.dll的引用.而且,如果您想使用.net framework Console类,则可以编写 global :: System.Console.WriteLine("hello");

Assume that your library also has a Console class & your CS file has a reference to your library and mscorlib.dll. And, if you would like to use .net framework Console class, you can write global::System.Console.WriteLine("hello");

在这种情况下,您还可以执行以下操作.

You can also do the following, in such a case.

using myConsole = MyLibrary.Console;
using fwkConsole = global::System.Console;

伙计们,如果我误解了这个问题,请纠正我.

Guys, correct me if I have misunderstood the question.

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

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