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. Globally accessible properties

Globally accessible properties

Scheduled Pinned Locked Moved C#
questionjsonhelp
2 Posts 2 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.
  • W Offline
    W Offline
    WetRivrRat
    wrote on last edited by
    #1

    hey all, i'm sure this is a dumb question: but... How do I create / access / modify properties that are available to all classes of my solution? iow, I have a main namespace, and multiple forms that are all separate classes/.dlls. I need to beable to access the properties of the main form throughout the rest of the application, regardless of whether or not the sub classes are instaniated yet. So.. ClassA(mainFrm) calls ClassB(subUsrCrtl1) which does some work then calls ClassC(subUsrCtrl2) which displays extended info from the work done in ClassB. Then ClassA can call ClassD(E,F,G,etc)(subUsrCrtl3(,4,5,6,etc)) who make other information available based on the work done in ClassB. Many of the classes that are available are not used everytime, so they aren't instantiated yet. I need to beable to retrieve data from the work that is completed in ClassB and use that data throughout all available classes. Currently I'm only able to access that data in a class to class relationship where I end up with either old or null values becuase i'm having to instantiate the required class again from the current class...(i.e. ClassA calls ClassD, ClassD needs data from ClassB, so ClassD instantiates new ClassB but that returns null data...) hope this make sense, cause i'm lost.... ehlp.... wait i can't even spell help...

    string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

    B 1 Reply Last reply
    0
    • W WetRivrRat

      hey all, i'm sure this is a dumb question: but... How do I create / access / modify properties that are available to all classes of my solution? iow, I have a main namespace, and multiple forms that are all separate classes/.dlls. I need to beable to access the properties of the main form throughout the rest of the application, regardless of whether or not the sub classes are instaniated yet. So.. ClassA(mainFrm) calls ClassB(subUsrCrtl1) which does some work then calls ClassC(subUsrCtrl2) which displays extended info from the work done in ClassB. Then ClassA can call ClassD(E,F,G,etc)(subUsrCrtl3(,4,5,6,etc)) who make other information available based on the work done in ClassB. Many of the classes that are available are not used everytime, so they aren't instantiated yet. I need to beable to retrieve data from the work that is completed in ClassB and use that data throughout all available classes. Currently I'm only able to access that data in a class to class relationship where I end up with either old or null values becuase i'm having to instantiate the required class again from the current class...(i.e. ClassA calls ClassD, ClassD needs data from ClassB, so ClassD instantiates new ClassB but that returns null data...) hope this make sense, cause i'm lost.... ehlp.... wait i can't even spell help...

      string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

      B Offline
      B Offline
      Bijesh
      wrote on last edited by
      #2

      If you want values to be used across different instances it is better to make those properties as static members of the class and access them from the class scope. A better approach would be to take out the information you want to make available across the application and put them into one class. Make a static instance of that class to use across the other classes.

      --------------------------------------------------

      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