嘿,我需要使用一个Int方法Main中的方法ValidateAns中的一个叫做点的方法。我搜索周围的网和人说我应该做的ValidateAns(点),但它不为我工作,林不知道如果我做错了,或者我应该使用一些其他的方式来做到这一点在另一种方法中使用int
static void Main(string[] args)
{
const int QuestionNumbers = 10;
char[] Answear = new char[QuestionNumbers];
Question[] MCQ = new Question[QuestionNumbers];
MCQ[0] = new Question(Slaughterhouse);
MCQ[1] = new Question(Frankenstein);
MCQ[2] = new Question(Things);
MCQ[3] = new Question(Jane);
MCQ[4] = new Question(Kill);
MCQ[5] = new Question(Beloved);
MCQ[6] = new Question(Gatsby);
MCQ[7] = new Question(Catcher);
MCQ[8] = new Question(Pride);
MCQ[9] = new Question(Nineteen);
for (int i = 0; i < QuestionNumbers; i++)
{
Console.WriteLine("Question {0}", i + 1);
Answear[i] = MCQ[i]();
ValidateAns(i + 1, Answear[i]);
Console.WriteLine();
Console.ReadKey();
}
}
static void ValidateAns(int Nbr, char Ans)
{
int points= 0;
switch (Nbr)
{
case 1:
if (Ans == 'b' || Ans == 'B')
{
Console.WriteLine("Good Answear");
points++;
break;
}
else
{
Console.WriteLine("Wrong Answer - The right answer was (B)");
break;
}
}
}
你可以从'ValidateAns'返回'bool'来表示答案是否正确。在循环逻辑中,如果“bool”为true,则将向点的计数器加1。 – SimpleVar 2014-08-30 14:30:05
我觉得这个问题不应该有标签[visual-studio-2012]! – 2014-08-30 16:15:48