What's a “static method” in C#?

前端 未结 9 2177
再見小時候
再見小時候 2020-11-22 06:48

What does it mean when you add the static keyword to a method?

public static void doSomething(){
   //Well, do something!
}

Can you add the

9条回答
  •  不要未来只要你来
    2020-11-22 07:16

    Static function means that it is associated with class (not a particular instance of class but the class itself) and it can be invoked even when no class instances exist.

    Static class means that class contains only static members.

提交回复
热议问题