on-internet
← Community

C#: ensure static variable retains its value

Stack Overflow ·

Goal: I am having some issues in C# when ensuring that a variable retains its assigned value for the duration / runtime of a program. In particular, I am attempting to: Read a number in from some input Save it to a variable of type double Print the variable Ensure that this value stays the same for the duration of the program, so that on the next iteration when a new value is read in, the previous value from step (2) is still printed. Attempts: I have attempted to use a global static variable such as public static double foo;, however, whenever the method that retrievs new values is called aga

Comments

Sign in or sign up to comment and upvote.

No comments yet.