Last active
January 20, 2021 12:31
-
-
Save DavidHulsman/81832568e400cde4e5f3f5889b8309f1 to your computer and use it in GitHub Desktop.
How not to .padLeft(3, '0') in C#
This file contains 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
// I found this little nugget 6 times in a 5000+ lines god-class, with the deepest indent being 23 tabs deep. | |
if (var.Length < 3) | |
{ | |
if (var.Length < 2) | |
{ | |
if (var == "") | |
{ | |
var = "000"; | |
} | |
else | |
{ | |
var += "00"; | |
} | |
} | |
else | |
{ | |
var += "0"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment