C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Then: You can create the main program, the console application, that specifies the extern aliases.
X and Y: The extern alias X and Y are meaningless unless they match the settings you specify in Visual Studio.
In Visual Studio: The X and Y aliases are mapped to the ClassLibrary1 and ClassLibrary2 DLL files.
Tip: You must specify the extern alias in your C# program, and also in the compilation system (Visual Studio).
C# program that uses extern alias syntax
extern alias X;
extern alias Y;
using System;
class Program
{
static void Main()
{
X.A._b = 1;
Y.A._b = 2;
Console.WriteLine(X.A._b);
Console.WriteLine(Y.A._b);
}
}
Contents of ClassLibrary1: C#
public class A
{
public static int _b;
}
Contents of ClassLibrary2: C#
public class A
{
public static int _b;
}
Output
1
2
Also: Extern is handy in large programs, or ones that use multiple versions of the same library at once.