C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Then: In the program, the type Cat can be used as a StringBuilder. This example makes the program more confusing.
C# program that shows using alias directive
using System;
using Cat = System.Text.StringBuilder;
class Program
{
static void Main()
{
Cat cat = new Cat();
cat.Append("sparky");
cat.Append(100);
Console.WriteLine(cat);
}
}
Output
sparky100
And: You could use an alias instead of the actual type names. Then you could use #ifdef and #else to wrap the using alias directive.
DirectivesIf, Elif, EndifWarning: The major drawback is that it can be abused to create programs that are extremely confusing.