C# port of MathDice

This commit is contained in:
Haydn Kane
2021-03-05 22:06:36 +00:00
parent dbfcc3dfc2
commit 56f3875b49
6 changed files with 185 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
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);
}
}
}