Menu Validation 'char input'
I just asking for some general directions to design a solid input validation for a menu.
It 'works' but I feel like I am using the wrong tools.
I want it to only use a key press, that is fine. The overall come I wrote doesn't feel solid.
6 Replies
First of all $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/just do if char=='1' or use switch to check cases from 1 to 4
and any other input will be invalid
you can resume it a bit further with
but in the end you would be using that result against a switch or some conditions to run more code
@GreenMile this might be of your interest https://gist.github.com/ZacharyPatten/798ed612d692a560bdd529367b6a7dbd
it shows various ways and scenarios on how to take console input
and how simple it can be
@GreenMile What Leo said is good advice. Also, unsure if you need it but, you can provide
ReadKey()
with a boolean true
to make it so that the pressed key doesn't appear in the terminal.
Make sense to use a switch for such scenario, thanks for replying!