Using Instances in Multiple Locations
Within a Form I am creating an Instance of
Then within the Form there is a Button that on Click i would like to
How can i do this?
9 Replies
store the instance of EdgeDriver in a field/property in your form
you need to do that anyway if you want that class instance to keep existing after your form constructor completes
So make it a Global Variable.
no, make it a member of your form class
that's not global, it only exists in that instance of your form and can't be accessed outside it
there is technically no such thing as a global variable in C#, the closest you can get is public static fields/properties
where in the Code would i need to pozition it for it to be classed as a member of the Form Class.
where do you position your methods to make them a member of the form class?
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/members
what would the Return type be?
look at the "fields" section in the page i linked
It is the Output that i would need to use multiple times not the Command. If i run the command multiple times it loads the driver multiple times.
once you store the driver in a field you can run whatever you want as many times as you want