How are partial methods used in C# 3.0?

前端 未结 5 1050
终归单人心
终归单人心 2020-12-31 02:57

I have read about partial methods in the latest C# language specification, so I understand the principles, but I\'m wondering how people are actually using them. Is there a

5条回答
  •  借酒劲吻你
    2020-12-31 03:32

    Partial methods are very similar in concept to the GoF Template Method behavioural pattern (Design Patterns, p325).

    They allow the behaviour of an algorithm or operation to be defined in one place and implemented or changed elsewhere enabling extensibility and customisation. I've started to use partial methods in C# 3.0 instead of template methods because the I think the code is cleaner.

    One nice feature is that unimplemented partial methods incur no runtime overhead as they're compiled away.

提交回复
热议问题