为什么这个c#代码无效。
Console.Write("What is your awesomeness level: ");
int Level = Convert.ToInt32(Console.ReadLine());
int Isaac_Level = Level + (100 * Level);
var remainder = Isaac_Level - Level;
if (Isaac_Level > Level)
{
Console.WriteLine("Isaac's Awesome Level is higher than yours by ", remainder);
}
其余部分有问题 - 它不会出现在Console.WriteLine的输出中。
我已经尝试了很多,请告诉我有什么问题。
答案 0 :(得分:1)
这里有语法错误:
Console.WriteLine("Isaac's Awesome Level is higher than yours by ", remainder);
改为使用:
Console.WriteLine("Isaac's Awesome Level is higher than yours by " + remainder);
或使用C#6功能:
Console.WriteLine($"Isaac's Awesome Level is higher than yours by {remainder}");
另外,当您希望用户阅读某些内容时,使用try catch语句进行转换和Console.ReadLine();