Console.ReadLine not getting correct input (C#)
Go to solution
Solved by Bartholomew,
12 minutes ago, EvilCat70 said:This is the entire thing. Mine is also in a for loop
for(; ; ) { if (Console.ReadLine() == "reload") { try { Bot.users.Clear(); Utils.cooldowns.Clear(); Utils.disabledMods.Clear(); Prices.prices.Clear(); Utils.GetUsersFile(out Bot.users); Utils.GetCooldowns(); Utils.GetDisabledMods(); Prices.GetAllPrices(); Console.WriteLine("Reloaded!"); } catch (Exception) { Console.WriteLine("Error while trying to reload. Please restart the program"); } } if (Console.ReadLine() == "hello") Console.WriteLine("Hello.");
Store the result of readline in a variable.
The first if is where your first hello is being ignored due to testing against reload.
Readline once, compare result multiple. Now you ask for a new inout line for each comparison, so on each attempt only one word can work (compare equal).
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now