Skip to content

Instantly share code, notes, and snippets.

@AverageMarcus
Created March 16, 2013 15:53
Show Gist options
  • Save AverageMarcus/5176985 to your computer and use it in GitHub Desktop.
Save AverageMarcus/5176985 to your computer and use it in GitHub Desktop.
Remove any trailing commas from comma separated concatenated strings.
public static string TrimTrailingComma(string value)
{
if (value.Length >= 2)
{
if(value[value.Length-1].Equals(" ") && value[value.Length-2].Equals(","))
{
value = value.Substring(0, value.Length - 2);
}
else if (value[value.Length - 1].Equals(","))
{
value = value.Substring(0, value.Length - 2);
}
}
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment