Search code examples
c#winformsvariablesresetundef

c# Quick way to undef all parameters


I have a C# winform app which is doing a lot of calculation. there is a "run" button to trigger the process. I would like to be able to "re-trigger or re-run or re-submit" the information without having to restart the program. Problem is I have a lot of variables that need to be reset. Is there a way to undef (reset) all parameters?

private Double jtime, jendtime, jebegintime, javerage, .... on and on

Solution

  • Create an instance of an object that stores these variables. Reference this object, and when wanting to "reset", reinstantiate your object. e.g.

    public class SomeClass
    {
       public double jTime;
       ...
    }
    
    ...
    
    SomeClass sc = new SomeClass();
    sc.jTime = 1;
    sc = new SomeClass();