views:

216

answers:

3

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?

Thanks.

+2  A: 

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.

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.

shahkalpesh
+3  A: 

You might have to reference two versions of assemblies that have the same fully-qualified type names. For example, you might have to use two or more versions of an assembly in the same application. By using an external assembly alias, the namespaces from each assembly can be wrapped inside root-level namespaces named by the alias, which enables them to be used in the same file.

CptSkippy
+1  A: 

I found this great article that shows how to use Alias property.

Vadim