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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Access properties from a class not belonging to the namespace

Access properties from a class not belonging to the namespace

Scheduled Pinned Locked Moved C#
questionannouncement
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.
  • E Offline
    E Offline
    ESTAN
    wrote on last edited by
    #1

    Hello, I have a class without a namespace. The main reason why I don't have a namespace in that class is because I use that class in all my applications. Now I like to update application settings in that class, but I don't like to use the following line in that class: using ApplicationNamespace.Properties; Is there a way where i can reference that up to my class?

    D 1 Reply Last reply
    0
    • E ESTAN

      Hello, I have a class without a namespace. The main reason why I don't have a namespace in that class is because I use that class in all my applications. Now I like to update application settings in that class, but I don't like to use the following line in that class: using ApplicationNamespace.Properties; Is there a way where i can reference that up to my class?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You may think that your class is not contained in a namespace, but it IS in one. The default name for a namespace is the name of the project.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You may think that your class is not contained in a namespace, but it IS in one. The default name for a namespace is the name of the project.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        E Offline
        E Offline
        ESTAN
        wrote on last edited by
        #3

        Well, that's the point, i would like to be able to copy the class everywhere without changing/adding the projects namespace into the class and still updating the namespace's settings. Maybe it is impossible, but i like to ask.

        C D 2 Replies Last reply
        0
        • E ESTAN

          Well, that's the point, i would like to be able to copy the class everywhere without changing/adding the projects namespace into the class and still updating the namespace's settings. Maybe it is impossible, but i like to ask.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Yeah, it is, you can't change the namespace your code is in.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          • E ESTAN

            Well, that's the point, i would like to be able to copy the class everywhere without changing/adding the projects namespace into the class and still updating the namespace's settings. Maybe it is impossible, but i like to ask.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Like Christian said, you can't do that. The namespace is part of the fully qualified name of the class. Changing it is out of the question. The only way you can use this class in other projects is to add a reference to it's .DLL. Importing the namespace is optional, but it saves you from having to type the full namespace/class path in your other project's code.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            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