Optional Parameter vs Empty Parameter Methods and Constructor with Overloading

Viewed 328

To put it simply, say you have two methods:

public static void WriteMessage() 
{
    Console.Write("Empty Parameter Function");
}



public static void WriteMessage(string data = "Some Data")
{
    Console.Write("Optional Parameter Function");
}

Why is it that if you call the WriteMessage function without any parameters, it runs the "Empty Parameter Function"? I understand method overloading, but why does not the optional parameter function run as if the empty parameter function didn't exist, it would run?

1 Answers
Related