Vs2012编译时指示索引数组溢出,求指教
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sl_15102004
{
class Program
{
static void Main(string[] args)
{
int[] a=new int[5]{1,2,3,4,5};
int[] b=new int[a.Length ];
int[] c= new int[a.Length];
b= a;
Console.WriteLine("输出b数组数据:");
foreach (int i in b)
{
Console.WriteLine(i);
}
for (int i = 0; i <= a.Length; i++)
{
c[i] = a[i];
}
Console.WriteLine("输出c数组数据:");
foreach (int i in c)
{
Console.WriteLine(i);
}
Console.WriteLine("改变a数组的第2个数据的值,请输入新的值:");
a[1] = Console.Read();
Console.WriteLine("输出a数组的数据:");
foreach (int i in a)
{
Console.WriteLine(i);
}
Console.WriteLine("输出b数组数据:");
foreach (int i in b)
{
Console.WriteLine(i);
}
Console.WriteLine("输出c数组数据:");
foreach (int i in b)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}