Extension interface patterns

后端 未结 11 2010
失恋的感觉
失恋的感觉 2020-12-14 16:56

The new extensions in .Net 3.5 allow functionality to be split out from interfaces.

For instance in .Net 2.0

public interface IHaveChildren {
    str         


        
11条回答
  •  無奈伤痛
    2020-12-14 17:26

    A little bit more.

    If multiple interfaces have the same extension method signature, you would need to explicitly convert the caller to one interface type and then call the method. E.g.

    ((IFirst)this).AmbigousMethod()
    

提交回复
热议问题