In a WinForms application I’m working on I’d like to have a properties class to store common variables that all the forms in the project could access in order to store and retrieve values as required.
In the past I’ve used a static class to store strings and int values etc, but those are fixed during coding and cannot be altered when the application is running. I’d like to use a properties class in the same manner if its possible so that I’d have read and write functionality.
Must I create an instance of the properties class in Form1.cs and then pass it around as a parameter in the constructor of other forms in order for them to access the fields in the properties class?
Or can this be done without instantiation?
If I’ve understood you correctly – you don’t need to do anything differently. You can change those while running.
You can have:
And use it: