using System;
class Program {
// *** before: ***
// a default value meant a family of overloads, each one forwarding to
// the next, and every new parameter doubled the family
static string ReportOld(string title) { return ReportOld(title, 10); }
static string ReportOld(string title, int width) { return ReportOld(title,
width, '.'); }
static string ReportOld(string title, int width, char fill) {
return title.PadRight(width, fill);
}
// *** in version 4.0: ***
static string Report(string title, int width = 10, char fill = '.') {
return title.PadRight(width, fill);
}
static void Main() {
Console.WriteLine(ReportOld("total"));
Console.WriteLine(Report("total"));
Console.WriteLine(Report("total", 15));
Console.WriteLine(Report("total", 15, '-'));
// a default has to be a constant, and the compiler writes it INTO
// the call: changing it in a library reaches the caller only after
// the caller itself is rebuilt
}
}