2015-04-05 33 views
0
namespace if4 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string username; 
      int password = new int(); 

      string userValue; 
      userValue = Console.ReadLine(); 

      Console.WriteLine("Enter your username:"); 
      userValue = Console.ReadLine(); 
      Console.WriteLine("Enter your password: "); 
      if (username == "code" && password == "55555") 
      { 
       Console.WriteLine("Access allowed! "); 
       Console.ReadLine(); 
      } 
      else 
      { 
       Console.WriteLine("Access denied! "); 
      } 
      Console.ReadLine(); 

     } 

    } 
} 
+0

這是什麼語言? C#? – 2015-04-05 13:52:43

回答

1

您無法將int與字符串進行比較,你需要聲明密碼爲字符串,而不是int,或者將「55555」轉換爲int,或者password == 555555

相關問題