jakeboss 2017-01-04 08:52 采纳率: 0%
浏览 1916
已结题

c#数组越界报错,怎么改 也没用,大神请教

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

namespace LIANXI
{
class Program
{

    static void Main(string[] args)
    {
        string str=Console.ReadLine();
        bool isAllUpperChar=true;
        for (int i = 0; i < 5; i++)
        {

            if(str[i] >= 'A' && str[i] <= 'Z')
            {


            }
            else
            {

               isAllUpperChar = false;
                break;

            }

        }
        if (isAllUpperChar==false)
        {
            Console.WriteLine("你输入的字母,不全是大写字母");
        }
        Console.ReadKey();

    }

}

}

按理不会有错,但是不知道具体什么问题,各位该怎么改正

  • 写回答

4条回答 默认 最新

  • bdmh 优质创作者: 移动开发技术领域 2017-01-04 09:01
    关注

    越界问题,你调试一下,应该很好找,你怎么知道一定小于5呢,看你输入的具体内容

    评论

报告相同问题?