In this example code i am using a simple StopWatch to test time that it takes to complete a given task/action
StopWatch SW1 = new StopWatch();
SW1.Start();
SomeAction();
SW1.Stop();
sting results = SW1.Elapsed.ToString();
MessageBox.Show(resutls);
i would like to have a class that i will instantiate to use with tests
public Class PerformanceTests
{
public StopWatch SW1 = new StopWatch();
public StopWatch SW2 = new StopWatch();
public string results1 = "", results2 = "";
....
....
//some other variables to use
}
though when instantiating the class and trying to use SW1 is not letting me use its methods. What am i doing wrong ?
PerformanceTests Ptst = new PerformanceTests();
Ptst.SW1. ... Start() is not accessible
Update
For rest of answers, don't copy the code from me, as I miss capitalized stopwatch. Instead of instantiating the Stopwatch class i accidentally didn't pay attention Visual Studio asking if i want to create a class for my so called stopwatch instead of .NET's real Stopwatch.
So my advice, pay attention to the suggested actions of Visual Studio intellisense even though it should be same all the time . Just make sure till you're really experienced and know all the classes by heart.