我收到錯誤Invalid Expression Term 'sbyte'
。」無效的表達式字節'sbyte'「
我對代碼很陌生,不完全確定我做錯了什麼。在從String
更改變量後,我得到錯誤,因爲數字將被輸入到行中,然後在代碼中使用。
爲什麼我會收到錯誤?
String Name = "";
String Team1 = "";
String Team2 = "";
String Team3 = "";
String Team4 = "";
sbyte Score1 = 0;
sbyte Score2 = 0;
sbyte Score3 = 0;
sbyte Score4 = 0;
String Winner1 = "";
String Winner2 = "";
Console.WriteLine("What's your name?");
Name = Console.ReadLine();
Console.WriteLine("Hello " + Name + ", enter the names of the 4 teams you want to see play below.");
Team1 = Console.ReadLine();
Team2 = Console.ReadLine();
Team3 = Console.ReadLine();
Team4 = Console.ReadLine();
Console.WriteLine("Ok, Here are todays matches");
Console.WriteLine("___________________________");
Console.WriteLine();
Console.WriteLine(Team1 + " vs " + Team2);
Console.WriteLine();
Console.WriteLine(Team3 + " vs " + Team4);
Console.WriteLine();
Console.WriteLine("___________________________");
Console.WriteLine();
Console.WriteLine("How many goals did " + Team1 + " Score?");
Score1 = sbyte (Console.ReadLine());
Console.WriteLine("How many goals did " + Team2 + " Score?");
Score2 = sbyte (Console.ReadLine());
Console.WriteLine("How many goals did " + Team3 + " Score?");
Score3 = sbyte (Console.ReadLine());
Console.WriteLine("How many goals did " + Team4 + " Score?");
Score4 = sbyte (Console.ReadLine());
Score1 = sbyte.Parse(Console.ReadLine()); – 2014-09-18 18:57:48