Reputation: 7671
It is annoying typing full name of a class like
myNamespace.y.calendar cal = new myNamespace.y.calendar();
(because asp.net already has a class name called calendar in System.web.ui.webcontrolls).
So to resolve this we can use like
using Calendar = myNamespace.y.calendar;
Calendar cal = new Calendar();
But how to do the same thing in asp.net aspx page?
Upvotes: 2
Views: 83
Reputation: 828
A little more info about Namespace Alias Qualifier. Just importing the namespace may not be sufficient if your class name is ambiguous with another class from a different namespace:
using colAlias = System.Collections;
namespace System
{
class TestClass
{
static void Main()
{
// Searching the alias:
colAlias::Hashtable test = new colAlias::Hashtable();
// Add items to the table.
test.Add("A", "1");
test.Add("B", "2");
test.Add("C", "3");
foreach (string name in test.Keys)
{
// Seaching the gloabal namespace:
global::System.Console.WriteLine(name + " " + test[name]);
}
}
}
}
Upvotes: 0