#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.

Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: