I want to know that, We have a class called Point is present in namespace N1 as well as in namespace N2, then what is the correct way to use the Point class?
Using class in C#
Hi friends,
I want to know that, We have a class called Point is present in namespace N1 as well as in namespace N2, then what is the correct way to use the Point class?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Dec 4, 2011, 5:20 PM
It is probably possible to have a "using" statement for one of the namespaces but not both of them and then you need to provide qualification for just one. That would work I think but in order to make the program easier for other programmers (and perhaps you in the future) to understand it would be better to use the full namespace names in situations where there are multiple possible qualifiers for the name.
Satyapriya NayakPosted Dec 4, 2011, 1:42 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace N1
{
class Point
{
public void abc()
{
System.Console.WriteLine("Hello abc");
}
}
}
namespace N2
{
class Point
{
public void def()
{
System.Console.WriteLine("Hello def");
System.Console.ReadLine();
}
}
}
class Execute
{
public static void Main()
{
N1.Point a1 = new N1.Point();
a1.abc();
N2.Point a2 = new N2.Point();
a2.def();
}
}
Thanks