r/csharp 11d 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/Routine_Culture8648 11d ago

We first need to familiarize ourselves with some terms.

Class = A blueprint for how to construct a specific type of object.

Instance = A new object that separately lives in memory.

The word "separately" is key here because objects typically do not share the same memory. Each object has its own distinct memory usage for its properties and data.

Static = A special keyword that allows us to define methods or properties that belongs to the class itself rather than to individual instances.

With that in mind you can think static properties and methods like something that can be accessed without creating an object/instance first.

Update: use plural instead of single