C# virtual static method

前端 未结 9 1301
盖世英雄少女心
盖世英雄少女心 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 02:08

    Eric Lippert has a blog post about this, and as usual with his posts, he covers the subject in great depth:

    http://blogs.msdn.com/b/ericlippert/archive/2007/06/14/calling-static-methods-on-type-parameters-is-illegal-part-one.aspx

    “virtual” and “static” are opposites! “virtual” means “determine the method to be called based on run time type information”, and “static” means “determine the method to be called solely based on compile time static analysis”

提交回复
热议问题