Files
basic-computer-games/61_Math_Dice/csharp/StringExtensions.cs
Chris Reuter d26dbf036a Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment.
This change fixes that.
2021-11-21 18:30:21 -05:00

16 lines
413 B
C#

namespace MathDice
{
public static class StringExtensions
{
private const int ConsoleWidth = 120; // default console width
public static string CentreAlign(this string value)
{
int spaces = ConsoleWidth - value.Length;
int leftPadding = spaces / 2 + value.Length;
return value.PadLeft(leftPadding).PadRight(ConsoleWidth);
}
}
}