C# virtual static method

前端 未结 9 1302
盖世英雄少女心
盖世英雄少女心 2020-12-14 01:27

Why is static virtual impossible? Is C# dependent or just don\'t have any sense in the OO world?

I know the concept has already been underlined but I did not find a

9条回答
  •  天命终不由人
    2020-12-14 01:44

    In .NET, virtual method dispatch is (roughly) done by looking at the actual type of an object when the method is called at runtime, and finding the most overriding method from the class's vtable. When calling on a static class, there is no object instance to check, and so no vtable to do the lookup on.

提交回复
热议问题