Answer the question
In order to leave comments, you need to log in
Who can suggest an article or a book where C# statics is well described?
Good afternoon Habrazhitel! I am a beginner C sharp programmer. It so happened that while reading and programming, I ignored the syntactic word static. Having already reached the topic about flows, I decided that I still need to learn this topic. In general, I don’t want to look at all the books in a row, knowing a kind and sympathetic toaster, which, I hope, will help me.
Answer the question
In order to leave comments, you need to log in
Actually everything is described in MSDN
Static Classes and Static Class Methods
Technically, static members of a class are members that live their lives independently of the objects of this class. If the entire class consists of such classes, then it can and should also be designated as static.
Usage example:
0. static void Main(){}
1. Implementation of the singleton pattern - support for one object per process. It's even possible to implement a single object through a static class, although I wouldn't do that.
2. Global parameters of objects. For example, the number of objects created, or a collection of objects.
3. A static class containing project parameters, constants or global project variables, as well as verification methods, tracing, etc., not tied to a specific class.
4. Extension methods are implemented through static methods. see MSDN
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question