C
C#2mo ago
blunt

✅ static r public?

I was writing code something like this, class Physics { public int Force; } and I was trying to access the Force variable I have, but it said I needed the variable to be static. Why was it asking me this when I already have public down?
No description
2 Replies
HtmlCompiler
HtmlCompiler2mo ago
because you have to actually create Physics with var myPhysics = new Physics(); just defining it doesn't put it in existence also because in that way you could not have more than one instance of it
Angius
Angius2mo ago
Non-static variables are only accessible from an instance of the class
Want results from more Discord servers?
Add your server