In this article, we will figure out how to utilize ‘using’ catchphrase in C#. What is ‘using’ catchphrase, how and when it is utilized in a C# program?
On the off chance that you need to incorporate namespace in a program, at that point we have to utilize using catchphrase.
For example, we use Console class which is characterized in System namespace that is the reason we have to incorporate System namespace using watchword.
In the event that we need to utilize Console class without incorporate, at that point we can likewise get to it with the assistance of. (spot) administrator like that:
System.Console.WriteLine("Hello World");
Example:
using System;
using System.Collections;
using namespace1;
using namespace2;
namespace namespace1
{
class ABC
{
public void fun()
{
Console.WriteLine("Inside Namespace1");
}
}
}
namespace namespace2
{
class XYZ
{
public void fun()
{
Console.WriteLine("Inside Namespace2");
}
}
}
class Program
{
static void Main()
{
ABC OB1 = new ABC();
XYZ OB2 = new XYZ();
OB1.fun();
OB2.fun();
}
}
Output
Inside Namespace1
Inside Namespace2