I know, I know, I am an incredible nit picker, but it gives me the willies to see the hard-coded string “\n” used for newline. It works and there is no real “correctness” argument to be made here, but I just don’t like it. Here are my reasons:
1. Not self documenting, the “new-guy” (or gal) may not know that “\n” means new line
2. It is unduly concrete rather than symbolic, making it hard for other software to reason of over the code.
3. Does not work across platforms.
Console.WriteLine(“\n” + name);
My suggested alternative is:
Or, if you must have it in one line,
Console.WriteLine(Environment.NewLine + name);
Now, aren’t those much better?