Reputation: 23
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
Upvotes: 1
Views: 806
Reputation: 335
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.
Upvotes: 1