+ 1
help with the code
hello, I need your help, as it turned out earlier, I'm not good at converting types, my code does not work and I do not even have the slightest idea how to fix it thank you in advance https://code.sololearn.com/cF48GVS135rd/?ref=app
8 Answers
+ 2
There were a few errors, this should work fine:
static void Main(string[] args)
{
Console.WriteLine("Enter password");
int password = Convert.ToInt32(Console.ReadLine());
if (password == 123456)
{
Console.WriteLine("Access is open");
Console.ReadLine();
}
else
{
Console.WriteLine("Wrong password");
Console.ReadLine();
}
}
+ 2
Delete the bool, it's not doing anything.
+ 2
I'm dumb...
Many thanks for the explanation, without you, I would not understand what the problem is =)
All the best! =)
+ 1
I should imagine it's because you've named the bool and int the same, so the for loop doesn't know which one to use.
+ 1
but how to make the code working?
+ 1
unfortunately does not help, there are two more errors
cannot implicitly convert type string to int
cannot implicitly convert type in to bool
https://code.sololearn.com/cF48GVS135rd/?ref=app
+ 1
If I wasn't on my phone I'd go into more detail but this should help:
int password = Convert.ToInt32(Console.ReadLine());
+ 1
I hope after all that has happened you have everything in order with the psyche =)