My code works - but is shows invalid string at the beggening for no reason
It works but it disiplays invalid string at the start i want to get rid of it
https://github.com/AbdulRaheemNazir/MiniApps/blob/main/Caesar%20Cipher%20Problem
GitHub
MiniApps/Caesar Cipher Problem at main · AbdulRaheemNazir/MiniApps
Contribute to AbdulRaheemNazir/MiniApps development by creating an account on GitHub.
5 Replies
still need help ?
yep
@Abdul Raheem Nazir
Change this line
choice = (char)Console.Read();
to
choice = Console.ReadKey().KeyChar;
The reason you need to make this change is
Console.Read()
reads the first character in AFTER you've pressed enter, pressing enter adds \r\n
characters
Which makes the next call to Console.ReadLine()
read these charactersWith KeyChar it will allow me to only allow to type one digit (so 1-9) in future I will add more options so i will have more options above 20
Change it to ReadLine then and parse the returned string