A simple visual divider.
(Another snippet I originally posted to CodeKeep.)
In perl, I could write "=" x80 to create a visual separator in my debug statements or report headers. Here is an equally crisp syntax to do the same in C#.
Code:
Environment.NewLine + String.Empty.PadRight(80,’=') + Environment.NewLine;
Notes:
This idea also works for strings that need to be trimmed to a specific length (think fixed width output files). Take the existing string, pad it to the desired length, then chop off the rest via a substring.
myString.PadRight(80 ,’ ‘).Substring(0, 80).TrimEnd(new char[] {‘ ‘});
