hello world 输出 olleh dlrow

        string s = "Hello World";     

        string[] s2 = s.Split(' ');
        for(int j=0;j<s2.Length;j++)
        {
            char[] c = s2[j].ToCharArray();
            int l = s2[j].Length;
            for (int i = 0;i <l/2;i++)
            {
                char t = c[i];
                c[i] = c[l - i - 1];
                c[l - i - 1] = t;
            }
            s2[j] = new string(c);
        }

        return string.Join(" ", s2);

 

 

更多方法可参考文档:http://www.cnblogs.com/kirinboy/archive/2010/04/23/reverse-a-string.html

posted @ 2012-10-12 23:27  顿金  阅读(356)  评论(0编辑  收藏  举报