Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created June 26, 2016 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/fb14be371486b0fa3659cc2542a41bc1 to your computer and use it in GitHub Desktop.
Save jianminchen/fb14be371486b0fa3659cc2542a41bc1 to your computer and use it in GitHub Desktop.
HexDecimal string - "08", remove leading zero
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