C#编程--数组,foreach遍历数组

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //数组
            int[] arr = { 1, 2, 3, 4, 5, 6, 7 };
            Console.WriteLine(arr.Length);
            Console.WriteLine(arr[0]);
            arr[1] = 90;
            Console.WriteLine(arr[1]);
            for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr[i]);
            }
            foreach (int i in arr)
            {
                Console.WriteLine(i);
            }
            Console.ReadKey();
        }
    }
}
 

本文出自 “Kenan_ITBlog” 博客,请务必保留此出处http://soukenan.blog.51cto.com/5130995/1076239

你可能感兴趣的:(C#)