What are, in your opinion, the pros/cons of the following extension method?
static class Log
{
public static string AddToLog(this string input)
{
Console.WriteLine(input);
return input;
}
public static string AddToLog(this string input, string format)
{
Console.WriteLine(format, input);
return input;
}
}
Usage scenario:
class Program
{
static void Main(string[] args)
{
string tableName = "Bills".AddToLog("Default table name is {0}");
"Starting...".AddToLog();
"Creating table".AddToLog();
}
}
Well they're static for a start, which is going to make testing more difficult and will couple everything more tightly.
I also personally think something like
Logger.Write("Starting..");
is more understandable than
"Starting...".AddToLog();