标题:Vs2012编译时指示索引数组溢出,求指教
取消只看楼主
返回
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-10-19
结帖率:0
已结贴  问题点数:20 回复次数:0 
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();
        }
    }
}
2015-10-21 11:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-458388-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038497 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved