c# - Why is possible to call static methods of a non-static class? -


taking consideration following class structure:

[public non-static class]

using unityengine; using system.collections;  public class gamemanager : monobehaviour {      public static void play() //static method     {         print("play audio!");     }  } 

another class calling:

using unityengine; using system.collections;  public class testclass : monobehaviour {      // use initialization     void start () {         gamemanager.play();     }      // update called once per frame     void update () {      } } 

because possible call method without instantiating class gamemanager?

from here

a static class same non-static class, there 1 difference: static class cannot instantiated

the fact it's not static class doesn't affect way static methods can used.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -