[問題] C#的新手問題
我剛學C#
有很多地方不懂
狀大膽子來這邊發問
希望板上的各位如果看到幼稚的問題請多多包含
namespace FirstCSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("請輸入密碼:");
string password;
password = Console.ReadLine();
if (password == "5618") { Console.WriteLine("pass"); }
else { Console.WriteLine("BYE"); }
Console.Read();
}
}
}
這是正確的程式碼
但是我想把
string password 改成用int宣告
可是會無法執行
請問可以改成用int宣告嗎
我自己想的內容是
Console.WriteLine("請輸入密碼:");
int password=5618;
password = Console.ReadLine();
if (password == "5618") { Console.WriteLine("pass"); }
else { Console.WriteLine("BYE"); }
Console.Read();
它執行錯誤
是哪裡錯誤了嗎
先感謝各位了
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.161.175.71
→
07/18 22:51, , 1F
07/18 22:51, 1F
→
07/18 22:52, , 2F
07/18 22:52, 2F
推
07/18 22:53, , 3F
07/18 22:53, 3F
→
07/18 22:53, , 4F
07/18 22:53, 4F
→
07/18 22:54, , 5F
07/18 22:54, 5F
→
07/18 23:01, , 6F
07/18 23:01, 6F
推
07/20 02:32, , 7F
07/20 02:32, 7F