for (int i = 0; i < values1.Length; i++) ;
                {
                    int a = 0;
                    int b = values1[a];
                    if (b < 60)
                    {
                        b = 59;
                    }
                    else
                    {
                        Double[] scor;
                        switch (b)
                        {
                            case 59:
                                scor[a] = 0.00; break;
                            case 60:
                                scor[a] = 1.00; break;
                            case 61:
                            case 62:
                            case 63:出现这个错误是什么意思啊

解决方案 »

  1.   

    你就是忘记给变量赋值,例如:
    Double[] scor = new Double[1];
      

  2.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;namespace jidianbate1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        Double gpa;
            Double sum1 = 0.00;
            Double sum2 = 0.00;        private void buttontj1_Click(object sender, EventArgs e)
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("请输入要添加的数据");
                }
                else
                {
                    listBox1.Items.Add(textBox1.Text);
                    textBox1.Text = "";
                }        }        private void buttonsc1_Click(object sender, EventArgs e)
            {
                if (listBox1.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请选择要删除的项目");
                }
                else
                {
                    listBox1.Items.Remove(listBox1.SelectedItem);
                }
            }        private void buttontj11_Click(object sender, EventArgs e)
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("请输入要添加的数据");
                }
                else
                {
                    listBox2.Items.Add(textBox2.Text);
                    textBox2.Text = "";
                }
            }        private void buttonsc11_Click(object sender, EventArgs e)
            {
                if(listBox2.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请选择要删除的项目");
                }
                else
                {
                    listBox2.Items.Remove(listBox2.SelectedItem);
                }
            }        private void button1_Click(object sender, EventArgs e)
            {
                int[] values1 = new int[this.listBox1.Items.Count];
                for (int i = 0; i < this.listBox1.Items.Count - 1; i++)
                {
                    int values = Convert.ToInt32(this.listBox1.Items[i].ToString().Trim());
                    values1[i] = values;
                }
                int[] values11 = new int[this.listBox2.Items.Count];
                for (int i = 0; i < this.listBox2.Items.Count - 1; i++)
                {
                    int values = Convert.ToInt32(this.listBox2.Items[i].ToString().Trim());
                    values11[i] = values;
                }
                if (values1.Length != values11.Length)
                {
                    MessageBox.Show("输入的成绩与学分个数不相符,请核对");
                }
                else
                {
                    for (int i = 0; i < values1.Length; i++) ;
                    {
                        int a = 0;
                        int b = values1[a];
                        if (b < 60)
                        {
                            b = 59;
                        }
                        else
                        {
                            Double[] scor;                        switch (b)
                            {
                                case 59:
                                    scor[a] = 0.00; break;
                                case 60:
                                    scor[a] = 1.00; break;
                                case 61:
                                case 62:
                                case 63:
                                    scor[a] = 1.33; break;
                                case 64:
                                case 65:
                                case 66:
                                    scor[a] = 1.67; break;
                                case 67:
                                case 68:
                                case 69:
                                    scor[a] = 2.00; break;
                                case 70:
                                case 71:
                                case 72:
                                case 73:
                                    scor[a] = 2.33; break;
                                case 74:
                                case 75:
                                case 76:
                                    scor[a] = 2.67; break;
                                case 77:
                                case 78:
                                case 79:
                                    scor[a] = 3.00; break;
                                case 80:
                                case 81:
                                case 82:
                                case 83:
                                    scor[a] = 3.33; break;
                                case 84:
                                case 85:
                                case 86:
                                    scor[a] = 3.67; break;
                                case 87:
                                case 88:
                                case 89:
                                    scor[a] = 4.00; break;
                                case 90:
                                case 91:
                                case 92:
                                case 93:
                                case 94:
                                    scor[a] = 4.33; break;
                                case 95:
                                case 96:
                                case 97:
                                case 98:
                                case 99:
                                case 100:
                                    scor[a] = 4.67; break;
                            }
                            sum1 += scor[a] * values11[a];
                            sum2 += values11[a];
                        }
                        a++;
                    }
                    gpa = sum1 / sum2;
                    label1.Text = gpa.ToString();
                }        }
        }
    }
    额。。  全发过来了
      

  3.   

    double[] scor = new double[大小];
      

  4.   


    double[] scor = new double[SIZE]; //SIZE 常量
    //如果SIZE不能确定,则可以考虑用List,ArrayList之类的动态创建
      

  5.   


    List<double> scor = new List<double>(); // 这样就行
    //不过我看了一下你的逻辑,定义一个Double够用了吧?
    double scor = 0.0;
      

  6.   

    List<double> scor = new List<double>(); 你想用数组的话用这个就可以。
      

  7.   


                else
                {
                    for (int i = 0; i < values1.Length; i++) ;
                    {
                        int a = 0;
                        int b = values1[a];
                        if (b < 60)
                        {
                            b = 59;
                        }
                        else
                        {
                            List<double> scor = new List<double>();                        switch (b)
                            {
                                case 59:
                                    scor.Add(0.00); break;
                                case 60:
                                    scor.Add(1.00); break;
                                case 61:
                                case 62:
                                case 63:
                                    scor.Add(1.33); break;
                                case 64:
                                case 65:
                                case 66:
                                    scor.Add(1.67); break;
                                case 67:
                                case 68:
                                case 69:
                                    scor.Add(2.00); break;
                                case 70:
                                case 71:
                                case 72:
                                case 73:
                                    scor.Add(2.33); break;
                                case 74:
                                case 75:
                                case 76:
                                    scor.Add(2.67); break;
                                case 77:
                                case 78:
                                case 79:
                                    scor.Add(3.00); break;
                                case 80:
                                case 81:
                                case 82:
                                case 83:
                                    scor.Add(3.33); break;
                                case 84:
                                case 85:
                                case 86:
                                    scor.Add(3.67); break;
                                case 87:
                                case 88:
                                case 89:
                                    scor.Add(4.00); break;
                                case 90:
                                case 91:
                                case 92:
                                case 93:
                                case 94:
                                    scor.Add(4.33); break;
                                case 95:
                                case 96:
                                case 97:
                                case 98:
                                case 99:
                                case 100:
                                    scor.Add(4.67); break;
                            }
                            sum1 += scor[a] * values11[a];
                            sum2 += values11[a];
                        }
                        a++;
                    }
                    gpa = sum1 / sum2;
                    label1.Text = gpa.ToString();
                }
      

  8.   

    变量名,不要重名。
     List<double> scorList = new List<double>();
                double scor = 0.00;
      

  9.   


    两个需要一个List就够了。
      

  10.   

    额。。 再追问一个问题
    在整个程序进行运算完之后  怎样对之前的数组清空。。
    就是在        gpa = sum1 / sum2;
                  label1.Text = gpa.ToString();
    之后 
    要不程序运算完之后  要想进行下次运算  用户只能关闭程序再打开  否则之前的数据会干扰结果  
    刚刚试过了
      

  11.   


    List有Clear()的方法,数组的全部置0就行了。
      

  12.   

    第一次写程序不写hello world肯定是会出错的啊!
      

  13.   

    刚开始学是这样子的,慢慢来,有问题可以咨询:software