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

前端 未结 9 2158
再見小時候
再見小時候 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 06:59

    Static variable doesn't link with object of the class. It can be accessed using classname. All object of the class will share static variable.

    By making function as static, It will restrict the access of that function within that file.

提交回复
热议问题