数组笔记

using System;

class ArrayAccess
{
    static void Main()
    {   
        int[] intArray=new int[10];
        for (int i=0;i<10;i++)
        {
            intArray[i]=i*10;
        }
        Console.WriteLine("列出数组对象intArray包含的所有元素值:");
       
        for(int i=0;i<intArray.Length;i++)
        {
            Console.WriteLine("intArray[{0}]:{1}",i,intArray[i]);
        }
        Console.ReadLine();
    }
}

using System;

class usingforeach
{
    static void Main()
    {    string[] strArray=new string[5];
        for (int i=0;i<5;i++)
        {
            strArray[i]="Value"+i;
        }
       
        foreach(string str in strArray)
        {   
            Console.WriteLine(str);
        }
       
        Console.ReadLine();
    }
}

原文地址:https://www.cnblogs.com/fslnet/p/2026310.html