Created
March 16, 2013 15:53
-
-
Save AverageMarcus/5176985 to your computer and use it in GitHub Desktop.
Remove any trailing commas from comma separated concatenated strings.
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
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