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

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -