In my post a week ago, I mentioned three ways to reverse a string. OK, I really meant three alternative ways to reverse a string. And the post was done from an algorithmic stand point of view. I guess in the real world, you can achieve this in just three lines of code:

public string Reverse(string s) { char[] c = s.ToCharArray(); Array.Reverse(c); return new string(c); }

But I think that from an interviewer’s perspective, the previous three approaches would definitely do better…

Be Sociable, Share!