我在計算考試分數時遇到了問題。使用未分配的本地,錯誤
int midterm,finalexam,makeupexam;
double average;
try
{
midterm=Int32.Parse(txtMidterm.Text);
finalexam=Int32.Parse(txtFinal.text);
}
catch
{
txtResult.Text="any mark has not been written";
}
average= midterm*30/100+finalexam*70/100;
if(average>=49.5 && finalexam>50)
{
txt.Result.Text="passed, average: "+average.To.String();
}
else
{
txtResult.Text="makeup stayed";
}
try
{
makeupexam=Int32.Parse(txtMakeUpExam.Text);
}
catch
{
txt.Result.Text="MakeUp's mark has not been written";
}
average= midterm*30/100+makeupexam*70/100;
if(average>=49.5 && makeupexam>50)
{
txtResult.Text="Passed: " + average;
}
else
{
txtResult.Text="failed, average: ", average;
}
該計劃說:」使用未分配的局部變量的「中期,finalexam,makeupexam」請幫我謝謝大家從現在開始:)
謝謝兄弟,現在是okey:) – 2014-10-02 09:42:32
我的榮幸@ErdemNayir :) – Neel 2014-10-02 09:47:37