Created
June 24, 2020 20:53
-
-
Save dannylloyd/223fbfacc1ed3e3fcbf874cb512f2d8c to your computer and use it in GitHub Desktop.
Padding with string instead of char literal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
public static string PadRight(this string input, int totalWidth, string paddingString){ | |
var rep = string.Concat(Enumerable.Repeat(paddingString, totalWidth-input.Length)); | |
return (input + rep); | |
} | |
public static string PadLeft(this string input, int totalWidth, string paddingString){ | |
var rep = string.Concat(Enumerable.Repeat(paddingString, totalWidth-input.Length)); | |
return (rep + input); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment