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

 

Advertisement