码迷,mamicode.com
首页 > 编程语言 > 详细

C#数组反转

时间:2015-05-06 22:26:02      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

static void Main(string[] arr)
        {
            string[] names = { "老杨1", "老李2", "老王3", "老牛4", "老虎5", "老磁6" };

            for (int i = 0; i < names.Length/2; i++)
            {
                string temp = names[i];
                names[i] = names[(names.Length - 1) - i];
                names[(names.Length - 1) - i] = temp;

            }
            for (int i = 0; i < names.Length; i++)
            {
                Console.WriteLine(names[i]);
            }
            Console.ReadKey();
        }
    }

 

C#数组反转

标签:

原文地址:http://www.cnblogs.com/zywf/p/4483368.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!