If my string has values as:
myString = "Good Morning,Good Night";
and I want to reverse the values in it like as follows:
I want the final values in the myString as:
myString = "Good Night,Good Morning";
How do I achieve this?
How about:
string myString = "Good Morning,Good Night";
string[] subStrings = myString.Split(',');
myString = string.Join(",", subStrings.Reverse());
Or if you like to write these as one liners:
myString = string.Join(",", myString.Split(',').Reverse());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With