#633 – The Implementation of A Partial Method Is Optional

A partial method is a method declared in one portion of a partial class and implemented in another.

    // Dog-1.cs
    public partial class Dog
        public string Name { get; set; }

        // Partial method declaration--no implementation here
        partial void Growl();

One interesting thing about partial methods is that implementing them is optional.  In other words, you may provide an implementation of the Growl method shown above, in a separate file containing additional implementation for the partial class Dog.  But the compiler won’t complain if you never provide an implementation for the Growl method.



About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #633 – The Implementation of A Partial Method Is Optional

  1. Pingback: #634 – Invoking Partial Methods That Have No Implementation « 2,000 Things You Should Know About C#

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 )

Connecting to %s

%d bloggers like this: