使用switch语句
C#用switch语句太麻烦了要好多标签,VB.NET快多了,lz还是用if 语句吧
C#程序代码示例(控制台程序)
static void Main(){
int score;
score =Covert.ToInt32(Console.ReadLine());
int ScoreRank = (int)(score / 10);
string Rank;
switch (ScoreRank){
case 10:Rank="优";break;
case 9:Rank="优";break;
case 8: Rank="良";break;
case 7: Rank="中";break;
case 6:Rank="及格";break;
default: Rank="不及格";
}
Console.WriteLine(Rank);
}