2
String user,newUser,newPassword, password, resposta, user1,pass1;
user = "admin";
password = "123";
Console.WriteLine("LOGIN\n");
body:
Console.WriteLine("Ja possui login?");
resposta = Console.ReadLine();
/*
gostaria de fazer com que a resposta acima lida pelo programa seja convertida para um unico caractere maiusculo para quando fizer a comparação não precisar colocar varias || dentro da condição.
*/
if (resposta.Equals("N"))
{
Console.Write("Digite novo usuario: \n");
newUser = Console.ReadLine();
Console.Write("Digite nova senha: \n");
newPassword = Console.ReadLine();
Console.WriteLine("Criado com sucesso!\nAgora faça Login!");
goto body;
}
else if (resposta.Equals("S"))
{
Console.Write("Digite usuario: \n");
user1 = Console.ReadLine();
if (user1.Equals(user))
{
Console.Write("Digite a senha: \n");
pass1 = Console.ReadLine();
if (pass1.Equals(password))
{
Console.WriteLine("Logado com Sucesso!");
}
else
{
Console.WriteLine("Senha incorreta, tente novamente:");
goto body;
}
}
else
{
Console.WriteLine("Usuario incorreto, tente novamente!");
goto body;
}
}
Console.Read();
+1, By the way, at the time of learning is the best time for this, because later becomes addiction write code "tied with wire". Practically all of us end up "tying with wire" at one time or another in less ideal conditions, even if against the will, but can not be "life principle" if the intention is to program of truth.
– Bacco
Thanks @Maniero
– Gabriel Bueno Rodrigues
I’m gonna rewrite everything, and I’m not gonna use it. This was a simple solution just for learning, I’m learning at university and this was just a test.
– Gabriel Bueno Rodrigues
Learn to do it the right way, once you do it the wrong way you start to form a wrong idea in your head and it gets harder and harder to do it right. And see the best way to say thank you on the [tour].
– Maniero
@Maniero a lot of difference in performance compared to
StartsWith()
?– Leandro Angelo