Classes and instantiating classes c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Classes and instantiating classes c#

Hi - I have a question on creating classes and methods.. In terms of the static notation when it comes to creating a method (private static void ) is static only used in console applications? And can they be used in Windows Form Apps as well.. and also in terms of creating a new class with method would can static be used to then just call the calls in the main method instead of instantiating the class as new in the main method ? I hope my question makes sense Thanks Trey

8th Jun 2019, 9:34 AM
Tracy Mulder
Tracy Mulder - avatar
1 Answer
+ 1
Yes. Static is not bound to Console. It is used in winforms as well. Hope you have access to a computer. Download visual studio community version. It is free. And try it yourself. Classes can be instantiated anywhere. In simple programs it will be in the main method, but in more complex programs it also eill be in other classes. For example You can create a dog in the main method. And have a leash created in the dog class.
8th Jun 2019, 10:44 AM
sneeze
sneeze - avatar