Answer the question
In order to leave comments, you need to log in
"Global" class in C#?
Hello. I know, in the last couple of days I've been tormenting the community with my questions, but...:D
Wrote a class to work with MySQL (a kind of model) from C#.
The application itself is built like this: application form->frame. Pages are already loaded into the frame.
But the problem is that in these same pages, the class for working with MySQL needs to be re-declared - and this is the creation of a new connection, extra code and other hassle.
How to make a class "global" - for example, to declare it once when initializing the application, and then just use it everywhere (in all pages and other classes of the application), without declaring and creating new connections to the DBMS?
I know that there is no concept of a global variable in C#, but still I think that people have already come up with something :)
Answer the question
In order to leave comments, you need to log in
First, take a look at Dapper instead of inventing your own ORMs for MySQL.
Secondly, static properties of the class can be used as "global" variables .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question