数组杂记

int[] nums = { 12,13,14,15,16,17,18}; //初始化字符串
            int length = Convert.ToInt32(nums.Length);//转化
            //Console.WriteLine(length); length=7
            string[] str = new string[length];
            for (int i = 0; i < str.Length; i++)
            {
                str[i] = Convert.ToString(nums[i]);
            }
            //输出新数组
            Console.Write("新数组是:");
            for (int i = 0; i < str.Length; i++)
            {
                Console.Write(" "+str[i]);
            }

                Console.WriteLine();

 

posted @ 2017-02-15 11:01  一直为你守候  阅读(135)  评论(0编辑  收藏  举报