2014-01-12 2 views
-5

내 코드 : 여기동일한 자습서 코드가 컴파일 되더라도 내 코드가 컴파일되지 않습니다.

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); 
     } 
    } 
} 

무엇 그것은 내가 잘못하고있는 것이지만 어디서나 찾을 수는 없습니다. 자습서 웹 사이트의 복사하여 붙여 넣은 코드는 완벽하게 컴파일되고 실행되지만 내 코드는 완벽하게 실행되지 않습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

+2

분명히 편지로 문자로 검색하지 않았다 –

+0

** 심각하게? ** Visual Studio에 넣을 때 오류 목록에'; 예상 '과 *는 오류 *를 강조 표시합니다. 두 파일의 diff를 묻는 질문이 StackOverflow를 잘 사용한다고 생각하지 않습니다. 내가 할 수 있다면 -5 할 것이다. – Harrison

+0

Ctrl + A를 누른 다음 두 번째 코드 블록과 VS에서 Ctrl + V를 누릅니다 – Jim

답변

0

처음에는 :이 아닌 ;이 필요합니다. 따라서 using System;이 아니고 using System:이 아야합니다.

+0

* FACEPALM * 어떻게 알지 못했습니까? XD StackOverflow가 허용하는대로 귀하의 답변을 수락합니다. –

+0

@Prince_of_Oriel, 다른 게시물에서 IDE 대신 메모장 ++을 사용한다고 언급했습니다. IDE는 이와 같은 작은 실수를 찾는 데 도움을줍니다. VS를 구할 수 없다면 [MonoDevelop] (http://monodevelop.com/)을 사용하는 것이 좋습니다. – pcnThird

+0

@pcnThird Visual Studio를 실행할 수없는 것과 같은 이유로 MonoDevelop를 실행할 수 없다는 내용도 언급했습니다. 내 PC는 Windows XP (서비스 팩 2)입니다. –

관련 문제