#634 – Invoking Partial Methods That Have No Implementation

partial method is a method declared in one portion of a partial class and implemented in another.  You can also declare a partial method in one place, but not provide an implementation.

What happens, however, if the class that includes the partial method declaration includes a call to the partial method, but then you never provide the implementation?

For example, assume that we declare Dog.Growl as a partial method in the following file, but then never provide an implemenation of Growl.

    public partial class Dog
    {
        public void BeAggressive()
        {
            Console.WriteLine("Woof");

            // Invoke partial method
            Growl();

            Console.WriteLine("Done being aggressive");
        }

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

If you compile this and your code does not include an implementation for the Growl method, the compiler does not complain. It just quietly removes the call to the Growl method.