Created
June 26, 2016 17:12
-
-
Save jianminchen/fb14be371486b0fa3659cc2542a41bc1 to your computer and use it in GitHub Desktop.
HexDecimal string - "08", remove leading zero
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
private static string removeStarting0(string s) | |
{ | |
StringBuilder sb = new StringBuilder(); | |
bool skipFirst0s = true; | |
foreach (char c in s) | |
{ | |
if (c == '0' && skipFirst0s) | |
{ | |
continue; | |
} | |
else | |
{ | |
skipFirst0s = false; | |
sb.Append(c); | |
} | |
} | |
return (sb.ToString().Length == 0) ? "0" : sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment