You can sort the comma separated values in the string by using below function.
public string SortCommaSeparatedString(string name) { string[] stringArray = name.Split(','); Array.Sort(stringArray); string returnValue = ""; for (int i = stringArray.GetLowerBound(0); i <= stringArray.GetUpperBound(0); i++) { returnValue = returnValue + stringArray[i] + ","; } return returnValue.Remove(returnValue.Length-1,1); }
You can call above function as shown below:
string name="Amit,Piyush,Anushka,Priya,Shreya,Ipun"; name=SortCommaSeparatedString(name);
|
No responses found. Be the first to respond and make money from revenue sharing program.
|