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. Static Variables

Static Variables

Scheduled Pinned Locked Moved C#
9 Posts 6 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.
  • R Offline
    R Offline
    Ruchi03
    wrote on last edited by
    #1

    Can I change the value of a Static Variable....

    D K A 3 Replies Last reply
    0
    • R Ruchi03

      Can I change the value of a Static Variable....

      D Offline
      D Offline
      darkcalin
      wrote on last edited by
      #2

      yes :-D

      R 1 Reply Last reply
      0
      • D darkcalin

        yes :-D

        R Offline
        R Offline
        Ruchi03
        wrote on last edited by
        #3

        I would like to know how... i have already given it a value and now i want to change it again in my programm....:sigh:

        C S D 3 Replies Last reply
        0
        • R Ruchi03

          I would like to know how... i have already given it a value and now i want to change it again in my programm....:sigh:

          C Offline
          C Offline
          Chatura Dilan
          wrote on last edited by
          #4

          just like you change the value of non static variables. static variables are not final variables

          Chatura Dilan

          1 Reply Last reply
          0
          • R Ruchi03

            I would like to know how... i have already given it a value and now i want to change it again in my programm....:sigh:

            S Offline
            S Offline
            Stefan Troschuetz
            wrote on last edited by
            #5

            ClassName.VariableName = newValue;


            "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

            www.troschuetz.de

            R 1 Reply Last reply
            0
            • R Ruchi03

              Can I change the value of a Static Variable....

              K Offline
              K Offline
              Keshav V Kamat 0
              wrote on last edited by
              #6

              if u are using a windows form, try using a separate class within which you declare the public static member, so that it can be used with the class name. its value does change.

              Keshav Kamat :) India

              1 Reply Last reply
              0
              • S Stefan Troschuetz

                ClassName.VariableName = newValue;


                "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

                www.troschuetz.de

                R Offline
                R Offline
                Ruchi03
                wrote on last edited by
                #7

                I got it... Thanks to all

                1 Reply Last reply
                0
                • R Ruchi03

                  I would like to know how... i have already given it a value and now i want to change it again in my programm....:sigh:

                  D Offline
                  D Offline
                  darkcalin
                  wrote on last edited by
                  #8

                  class unu { public static int varStatic=0; ............ } class doi { public void myMetod() { unu obj=new unu(); obj.varStatic=10; } ....... } :doh: i hoppe this code work :sigh:

                  1 Reply Last reply
                  0
                  • R Ruchi03

                    Can I change the value of a Static Variable....

                    A Offline
                    A Offline
                    Abolfazl Sheikhloo
                    wrote on last edited by
                    #9

                    if you are building a webproject application, using from static variables not a good method you can use ViewState similar static variables

                    We Can Do Anything, If We Want It

                    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