#636 – The Reason for Partial Methods

Partial methods allow one portion of a class to declare one or more methods and then another portion of the class, in a different file, to optionally implement one or more of those methods.

You’ll typically see partial methods used when some tool generates a portion of a class and the user (developer) is expected to develop the remainder of the class.  The class in question is a partial class, because it is split across two (or more) files–the tool-generated part and the user-generated part.

Using partial methods, the tool-generated code can declare a number of optional methods that are basically extensibility points for the user-generated code.  The tool-generated will call these methods, but only if the user decides to implement them.  If the user does not implement them, they are simply not called.

Advertisement