私のプログラムはエラーを出さないが動作しないので、コマンドウィンドウを終了するときに名前とパスワードを尋ねる。私のプログラムでC#論理エラー?
お願いします。
namespace password
{
class Program
{
static void Main(string[] args)
{
String Samsonpass = "12345";
String Riazpass = "hyperion";
String mypass = "CSGOPRO";
String Samson = "Samson";
String Riaz = "Riaz";
String Curstin = "Curstin";
Console.Write("Enter your name :");
string answer = Console.ReadLine();
Console.Write("Enter your password :");
string password = Console.ReadLine();
if (answer == Curstin && password == mypass)
{
Console.Write("Welcome Curstin");
}
else if (answer == Riaz && password == Riazpass)
{
Console.Write("Welcome Riaz");
}
else if (answer == Samson && password == Samsonpass)
{
Console.Write("Welcome Samson");
}
else
{
Console.Write("Invalid user or password !");
}
}
}
}
何も残していないので、終了します。開いたままにする必要がある場合は、プログラムの最後に 'Console.ReadKey();'の行に沿って何かを試してみてください。 –
コマンドシェルで直接プログラムexeを呼び出します。コマンドウィンドウが閉じず、出力が表示されます –