VB.NET: impossible to use Extension method on System.Object instance

后端 未结 6 1051
南方客
南方客 2020-12-03 09:49

Can I make an Extension method for all the subclasses of System.Object (everything)?

Example:


Public Function MyExtens         


        
6条回答
  •  天涯浪人
    2020-12-03 10:23

    It seems like not supporting Extension methods on Object was a design decision in VB.

    As a result, the only way we could prevent extension methods from completely breaking existing late bound code was to prevent them from being used on anything typed as object.

    http://blogs.msdn.com/b/vbteam/archive/2007/01/24/extension-methods-and-late-binding-extension-methods-part-4.aspx

提交回复
热议问题