Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem in using namespace in c#

Problem in using namespace in c#

Scheduled Pinned Locked Moved C#
csharpcomhelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DIPAK EMSYS
    wrote on last edited by
    #1

    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.com

    dipak

    S 1 Reply Last reply
    0
    • D DIPAK EMSYS

      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.com

      dipak

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      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.

      D 1 Reply Last reply
      0
      • S SeMartens

        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.

        D Offline
        D Offline
        DIPAK EMSYS
        wrote on last edited by
        #3

        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

        H 1 Reply Last reply
        0
        • D DIPAK EMSYS

          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

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          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.”

          D 1 Reply Last reply
          0
          • H Henry Minute

            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.”

            D Offline
            D Offline
            DIPAK EMSYS
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups