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
Post a Comment