using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication6
{
class Average2
{
static void Main(string[] args)
{
int total, gradeCounter,gradeValue;
double average;
total = 0;
gradeCounter = 0;
Console.Write("Enter Integer grade,-1 to Quit:");
gradeCounter = Int32.Parse(Console.ReadLine());
if ( gradeCounter == -1 )
{
Console.WriteLine("No grades were entered.");
}
while (gradeValue != -1)
{
total = total + gradeValue;
gradeCounter = gradeCounter + 1;
Console.Write("Enter Integer Grade,-1 to Quit: ");
gradeCounter = Int32.Parse(Console.ReadLine());
average = (double)total / gradeCounter;
Console.WriteLine("\nClass average is {0}", average);
}
}
}
}
请帮我看一下这个问题出错了:提示上说, 使用了未赋值的局部变量“gradeValue”
但是我随便赋了一个值.要不能实现哨兵这个功能.