Why is it useful to access static members “through” inherited types?

后端 未结 2 920
故里飘歌
故里飘歌 2020-12-29 06:55

I\'m glad C# doesn\'t let you access static members \'as though\' they were instance members. This avoids a common bug in Java:

Thread t = new Thread(..);
t.         


        
2条回答
  •  时光取名叫无心
    2020-12-29 07:16

    This is useful in WinForms.

    In any control or form, you can write MousePosition, MouseButtons, or ModifierKeys to use the static members inherited from Control.

    It's still debatable whether it was a good decision.

提交回复
热议问题