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. Hw can i make a variable visible in whole window project?

Hw can i make a variable visible in whole window project?

Scheduled Pinned Locked Moved C#
question
4 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.
  • B Offline
    B Offline
    Binod K
    wrote on last edited by
    #1

    Hi, I require to get a value of varaibale in whole project. How can I ? For exameple, In starting of applicaton i initialize the variable's state. That i require on several Form. I cannot change the name of variable. Any one tried this.Plz give me some hints.... Binod K.

    M 1 Reply Last reply
    0
    • B Binod K

      Hi, I require to get a value of varaibale in whole project. How can I ? For exameple, In starting of applicaton i initialize the variable's state. That i require on several Form. I cannot change the name of variable. Any one tried this.Plz give me some hints.... Binod K.

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, You could use a const or static variable. //mainformcode public const int constint = 100; public static int staticint = 100; public Form1() { InitializeComponent(); } //other class int i1 = Form1.constint; //setting a const variable is not possible at this point (Form1.constint = 200, will not compile) int i2 = Form1.staticint; Form1.staticint = 200; All the best, Martin

      C 1 Reply Last reply
      0
      • M Martin 0

        Hello, You could use a const or static variable. //mainformcode public const int constint = 100; public static int staticint = 100; public Form1() { InitializeComponent(); } //other class int i1 = Form1.constint; //setting a const variable is not possible at this point (Form1.constint = 200, will not compile) int i2 = Form1.staticint; Form1.staticint = 200; All the best, Martin

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        Martin# wrote:

        You could use a const or static variable

        A const variable? (const = constant, which means it doesn't change; variable meaning it does change) :-D


        Upcoming events: * Glasgow: Geek Dinner (5th March) * Edinburgh: Web Security Conference Day for Windows Developers (12th April) My: Website | Blog | Photos

        M 1 Reply Last reply
        0
        • C Colin Angus Mackay

          Martin# wrote:

          You could use a const or static variable

          A const variable? (const = constant, which means it doesn't change; variable meaning it does change) :-D


          Upcoming events: * Glasgow: Geek Dinner (5th March) * Edinburgh: Web Security Conference Day for Windows Developers (12th April) My: Website | Blog | Photos

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          :laugh: You got me! All the best, Martin

          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