AI智能
改变未来

C#学习.string练习

     1.//将字符串\”abcdefg\”按照”gfedcba“输出

   static void Main(string[] args)
        {
            string str = \”abcdefg\”;
            char[] ch = str.ToCharArray();
            for (int i = 0; i < ch.Length / 2; i++)
            {
                char temp = ch[i];
                ch[i] = ch[ch.Length – 1 – i];
                ch[ch.Length – 1 – i] = temp;
            }
            str = new string(ch);
            Console.WriteLine(str);

            Console.ReadLine();
        }

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » C#学习.string练习