我的代碼:即使相同的教程代碼編譯,什麼使得我的代碼不能編譯?
using System:
namespace Hero2
{
class Program
{
static void Main(string[] args)
{
int herohitpoints, monsterhitpoints, attackdamage;
herohitpoints = 20;
monsterhitpoints = 15;
attackdamage = 8;
Console.WriteLine("The hero has {0}hp and the monster has {1}hp.", herohitpoints, monsterhitpoints);
do
{
herohitpoints -= attackdamage;
monsterhitpoints -= attackdamage;
Console.WriteLine("The hero attacks for {0}hp of damage", attackdamage);
Console.WriteLine("The monster attacks for {0}hp of damage", attackdamage);
Console.WriteLine("The hero now has {0}hp and the monster has {1}hp", herohitpoints, monsterhitpoints);
Console.ReadLine();
}
while (herohitpoints >0&&monsterhitpoints>0);
}
}
}
這裏是我一直在複製下來的教程代碼:
using System;
namespace Hero3
{
class Program
{
static void Main(string[] args)
{
int herohitpoints, monsterhitpoints, attackdamage;
herohitpoints = 20;
monsterhitpoints = 15;
attackdamage = 8;
Console.WriteLine("The hero has {0}hp, and the monster has {1}hp", herohitpoints,monsterhitpoints);
do
{
herohitpoints -= attackdamage;
monsterhitpoints -= attackdamage;
Console.WriteLine("The hero attacks for {0}hp of damage", attackdamage);
Console.WriteLine("The monster attacks for {0}hp of damage", attackdamage);
Console.WriteLine("The hero now has {0}hp, and the monster has {1}hp",herohitpoints, monsterhitpoints);
Console.ReadLine();
}
while (herohitpoints >0&&monsterhitpoints>0);
}
}
}
我已經花了一封信在最後一小時搜索通過這封信,試圖看到什麼這是我做錯了,但我無法在任何地方找到它。 從教程網站複製粘貼的代碼編譯和運行完美,但我的不會。我究竟做錯了什麼?
很明顯,你沒有通過'逐個字母'的搜索' –
**嚴重?**當把它放入Visual Studio的錯誤列表顯示';預計「和*突出顯示錯誤*。我不認爲一個問題要求兩個文件的差異是一個很好的使用StackOverflow。如果可以,我會-5。 – Harrison
Ctrl + A然後按Ctrl + C第二塊代碼,然後按Ctrl + V在VS – Jim