将一个字符串数组的元素顺序进行反转。{“我”,“是”,“中国人”}
最终结果{“中国人”,“是”,“我”}

			//方法一
			List<string> str = new List<string>() { "我", "是", "中国人" };
            str.Reverse();
            for (int i = 0; i < str.Count; i++)
            {
                Console.Write(str[i]+"   ");
            }
            Console.WriteLine();
            //方法二
            string[] str1 = { "我", "是", "中国人" };
            string[] str2 = new string[str1.Length];
            for (int i = 0; i < str1.Length; i++)
            {
                str2[i] = str1[str1.Length - 1 - i];
            }
            for (int i = 0; i < str2.Length; i++)
            {
                Console.Write(str2[i]+"   ");
            }
            Console.ReadLine();

posted on 2019-01-28 16:38  豆皮没有豆  阅读(468)  评论(0)    收藏  举报