Why can't you call a non-static method from a static method?

后端 未结 9 469
北海茫月
北海茫月 2020-12-03 19:32

I have a static method [Method1] in my class, which calls another method [Method2] in the same class and is not a static method. But this is a no-no. I get this error:

9条回答
  •  离开以前
    2020-12-03 19:50

    Simple rule of thumb is:

    A static method/class/ctor can never ever [use/call/invoke/what the heck you name the verb] call a non-static field, property, or method. But, calling by means of instantiation.

提交回复
热议问题