I have problem with my code:
using System;
using System.Threading;
namespace popo
{
public class Human
{
public static void Main()
{
Console.Write("Login: ");
public string LogInput = Console.Read();
if(LogInput=="ADMIN")
{
System.Console.Write("Password: ");
public string PassInput = Console.Read();
if(PassInput == "ADMIN")
{
System.Console.Write("L");
Thread.Sleep(1000);
System.Console.Write("O");
Thread.Sleep(1000);
System.Console.Write("G");
Thread.Sleep(1000);
System.Console.Write("G");
Thread.Sleep(1000);
System.Console.Write("E");
Thread.Sleep(1000);
System.Console.Write("D");
}
}
}
}
}
When Im trying to compile it, compiler says:
Mm.cs(10,38): error CS1513: } expected
Mm.cs(12,13): error CS1519: Invalid token 'if' in class, struct, or interface member declaration
Mm.cs(12,24): error CS1519: Invalid token '==' in class, struct, or interface member declaration
Mm.cs(14,37): error CS1519: Invalid token '(' in class, struct, or interface member declaration
Inside your Main()
function, the local variables LogInput
and PassInput
must be declared without the public
keyword. Also, replace Console.Read()
by Console.ReadLine()
. Thus your Main()
should look like this:
public static void Main()
{
Console.Write("Login: ");
string LogInput = Console.ReadLine();
if(LogInput=="ADMIN")
{
System.Console.Write("Password: ");
string PassInput = Console.ReadLine();
if(PassInput == "ADMIN")
{
// further as you had it...
}
}
}
Check this DotNetFiddle .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.