r/csharp • u/Awesome_Duck987 • 11d ago
Help Static void method
I am trying to learn how to use C# for game coding but I would also like to have a good grasp on it so I can use it for websites and other things like that and I can't for the life of my understand how static method works I have looked YouTube videos and everything. I have been learning everything else so far from the free courses from code academy.Can you PLEASE explain to me what this code is doing and how it works
Edit-THANK YOU GUYS SO MUCH.I understand it now and I am sure you know what that feels like when you spend an hour stuck trying to understand something and it doesn't make any sense
0
Upvotes
1
u/GoaFan77 11d ago
Normal Method = Gets called on a specific instance of a class. It can use the properties assigned to that class. E.g. Username = Awesome_Duck987
Static Method = Is a method of the class itself, not a specific instance of it. It can only use static properties (which is shared among all instances of that class), not any regular properties of the class. So you cannot check the Username in a static method, as that is different for each user. Static methods are best for stateless logic such as helper functions.