Problem in using namespace in c#
-
Hi All, I have Class library with name and namespace Dipak.DataAccess and within this name space there is class called DataAccess. I have another class library with name and namespace Dipak.ESchool.Data and within this namespace there is class called StudentData. Now i have added reference of Dipak.DataAccess in Dipak.ESchool.Data and i have added using Dipak.DataAccess statement in StudentData class . While calling method of Dipak.DataAccess i have to use full name like DataAccess.DataAccess.GetDataSet(),after adding using Dipak.DataAccess statement. And when i changes namespace from Dipak.ESchool.Data to ESchool.Data i need not to give full name for method call i am able call with classname.methodname, no need to add namespace name. Can any one explain me why it is so? And what i need to do for correcting above problem.
namespace Dipak.DataAccess { public class DataAccess; { } //------------------------------------------------- using Dipak.DataAccess using Dipak.ESchool.Common; namespace Dipak.ESchool.Data { public class StudentData< { DataAccess.DataAccess.GetDataSet() //i want this call to be like DataAccess.GetDataSet() } }
Thanks Dipak Thesiya. dipak.thesiya@gmail.comdipak
-
Hi All, I have Class library with name and namespace Dipak.DataAccess and within this name space there is class called DataAccess. I have another class library with name and namespace Dipak.ESchool.Data and within this namespace there is class called StudentData. Now i have added reference of Dipak.DataAccess in Dipak.ESchool.Data and i have added using Dipak.DataAccess statement in StudentData class . While calling method of Dipak.DataAccess i have to use full name like DataAccess.DataAccess.GetDataSet(),after adding using Dipak.DataAccess statement. And when i changes namespace from Dipak.ESchool.Data to ESchool.Data i need not to give full name for method call i am able call with classname.methodname, no need to add namespace name. Can any one explain me why it is so? And what i need to do for correcting above problem.
namespace Dipak.DataAccess { public class DataAccess; { } //------------------------------------------------- using Dipak.DataAccess using Dipak.ESchool.Common; namespace Dipak.ESchool.Data { public class StudentData< { DataAccess.DataAccess.GetDataSet() //i want this call to be like DataAccess.GetDataSet() } }
Thanks Dipak Thesiya. dipak.thesiya@gmail.comdipak
Hi, you have to use the fullname DataAccess.DataAccess.GetDataSet because the compiler doesn't know if you write only one DataAcces what you mean: namespace or class. I suggest not to use the same name for a class and a namespace. That can cause too much trouble as you see. Regards Sebastian P.S.: What about naming the DataAccess-namespace "DataAccessLayer"?
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Hi, you have to use the fullname DataAccess.DataAccess.GetDataSet because the compiler doesn't know if you write only one DataAcces what you mean: namespace or class. I suggest not to use the same name for a class and a namespace. That can cause too much trouble as you see. Regards Sebastian P.S.: What about naming the DataAccess-namespace "DataAccessLayer"?
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
Thanks for your reply... I tried using ur solution...it works... But as far as concept is concerned ....i have included using statement as using Dipak.DataAccess....so at this point compiler will be knowing the clearly that this name space is referenced...what matters if same class name is there in namespace... :(
dipak
-
Thanks for your reply... I tried using ur solution...it works... But as far as concept is concerned ....i have included using statement as using Dipak.DataAccess....so at this point compiler will be knowing the clearly that this name space is referenced...what matters if same class name is there in namespace... :(
dipak
DIPAK@EMSYS wrote:
what matters if same class name is there in namespace...
What matters is that the M$ coders didn't provide for this scenario. FWIW I agree with you, but the fact remains that we have to work with the tools we have. If this is the first of VSs little annoyances that you have encountered, then you are a lucky, lucky chap. :-D
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
DIPAK@EMSYS wrote:
what matters if same class name is there in namespace...
What matters is that the M$ coders didn't provide for this scenario. FWIW I agree with you, but the fact remains that we have to work with the tools we have. If this is the first of VSs little annoyances that you have encountered, then you are a lucky, lucky chap. :-D
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
thanks buddy.. but as i have mentioned in my problem description that if i changes my namesapce from Dipak.ESchool.Data to only ESchool.Data it works fine. But with Dipak.ESchool.Data i have to make call like DataAccess.DataAccess.GetDataSet(). As per naming standerds for namespace we follows Compnyname.projectname.namespacename and thats what i have done... Dipak my compny name....DataAccess and ESchool my Project name ....
dipak