C
C#19h ago
Jexs

✅ Does it work like this?

Im trying to start off by declaring an int numb and having a user enter a number and if that number is 'one' 'two' 'three' 'four' the program would go and read it as regular numbers ive had a lot of help with it thanks to leo and a few others but its 3 in the morning and im just lagging out and this is far as ive got and what ive attempted https://paste.mod.gg/ujnngabhpvvz/0 codes to big to post in discord this is for switch case practice thanks!
BlazeBin - ujnngabhpvvz
A tool for sharing your source code with the world!
8 Replies
Denis
Denis19h ago
The current implementation seems quite weird. I'd read the input from the console, save that into a string variable and then put that through the switch to match "one", "two", etc. If nothing matches, loop back to ask the user to try again I recommend doing a ToLower() on the string so that it always matches the switch cases, even if you enter "tHrEe"
Jexs
JexsOP19h ago
Okay
SG97
SG9719h ago
I think they we're meant to practice int.TryParse and use the result with the switch statement but the syntax is not there
numb = (int.TryParse("one", out ).Console.ReadLine());
numb = (int.TryParse("one", out ).Console.ReadLine());
Denis
Denis19h ago
The int.Parse and int.TryParse, afaik, expect numeric characters and not the English word for the number. So, this int.Parse("123") and not int.Parse("one hundred and twenty three") That is quite possible, however, not apparent for me from the question 😄 thanks for the clarification
SG97
SG9719h ago
it's all good, this was discussed in #help-0 I think
Jexs
JexsOP18h ago
Is it okay to post in both places @SG97 ? I just posted here cause I got off for the night
Denis
Denis18h ago
I recommend not cross posting to avoid confusion Either stay here or the chat If you decide to keep this thread, then you could paste a link in the chat and ask for help? Not sure if that is fine with the mods
SG97
SG9718h ago
just keep it here, it's better linking the help thread is not generally adviced though

Did you find this page helpful?