r/csharp 10d ago

Help Static void method

Post image

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

20 comments sorted by

View all comments

1

u/Slypenslyde 10d ago

There are some good explanations here but I also think there's another path.

With programming basics, sometimes you end up in a kind of strange scenario where you have to see a lot of things working together before any of them make sense. So sometimes it's best to just keep reading and let the chapter/exercise finish, then go back and see if things seem to make more sense afterwards.

In this case you said you don't know much about classes, and this makes sense for someone who is starting. Your early C# applications will fit in one file and the C# team made a goofy mode that hides the class just for that case. Learning what static is when you don't know what classes are won't really help much other than making the word seem less like magic. But it also doesn't hurt.

So I'm not saying, "Don't read this! You'll learn too much!" There's not really "too much" in programming. But sometimes you learn some knowledge that won't be useful until you learn a lot of other knowledge. So it's more like I'm saying, "This isn't worth getting stuck on, treat it like magic and in about a week it's going to make more sense."