Static C# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Static C#

What is the “static” keyword in C#, in simple words if possible?

19th Nov 2021, 3:10 PM
HyperNova
HyperNova - avatar
2 Answers
+ 2
static makes so you can access variable or method through other classes For example if you need to change string that is assigned in main class but you want to change in other class you will need to make string static In Program.cs: public static string x; In Class1.cs: Program.x = "some text";
22nd Nov 2021, 11:00 AM
2004
2004 - avatar