日期:2014-05-17  浏览次数:21090 次

c# 字符串取反
请教c#字符串取反

string a1 = "A1B2C3D4";
想达到取反的结果是:D4C3B2A1

请教写个详细代码,达到以上要求。谢谢
C#

------解决方案--------------------
 static void Main(string[] args)
        {
            string a1 = "A1B2C3D4";
            string[] temp = new string[a1.Length / 2];
            for (int i = 0, j = 0; i < a1.Length && j <= a1.Length; i = i + 2, j++)
            {
                temp[j] = a1[i] + "" + a1[i + 1];
            }

            string result = string.Empty;
            for (int i = temp.Length - 1; i >= 0; i--)
            {
                result += temp[i];
            }

            Console.WriteLine(result);
        }

------解决方案--------------------
string str = "A1B2C3D4";
            int len = str.Length;
            int x = len;
            string str2 = "";
            for (int i = 0; i < len / 2; i++)