-1

In C# want to do something like this:

StringBuilder strBuilder = new StringBuilder();
strBuilder.append("123");

And then some code

//Outputs 321 (works for any text value)
rlandster
  • 7,294
  • 14
  • 58
  • 96
ArthurQ
  • 118
  • 1
  • 8

1 Answers1

0

In C#

public string Reverse(string s) {
    return new string(Array.Reverse(s.ToCharArray()));
}

From above 3.5 Framework:

public string Reverse(string s) {
    return new string(s.Reverse().ToArray());
}

See reference.

Community
  • 1
  • 1
Wasi Ahmad
  • 35,739
  • 32
  • 114
  • 161
  • If the first code sample was borrowed from somewhere it would be fair if you gave credits to the original author. – zerkms Dec 04 '16 at 23:58
  • @zerkms i agree but frankly speaking reversing a String in java or C# is not a difficult thing. i knew that previously. – Wasi Ahmad Dec 05 '16 at 00:00
  • Well, if you copy-paste someone's code, even if it's trivial - it's still not your solution. – zerkms Dec 05 '16 at 00:02