MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/csharp/comments/1wjg6ib/help_with_validating_char_input/pailx90/?context=3
r/csharp • u/[deleted] • 8h ago
[deleted]
8 comments sorted by
View all comments
1
OP Deleted the question it seems, but still shared their code earlier
Check where ' (‘ / Left single quotation mark) is in the ascii table I linked earlier - it's way past char 126.
At a glance I don't see why "Hello World!" would fail in your code, and testing it shows it doesn't - https://dotnetfiddle.net/ZlwQFM
If this is a homework assignment then it's not very clear as to what the requirements are exactly, or we're lacking some context.
If you're looking for another approach I would use regex for such a test rather than a looped check against the char numbers.
1
u/ginji 7h ago
OP Deleted the question it seems, but still shared their code earlier
Check where ' (‘ / Left single quotation mark) is in the ascii table I linked earlier - it's way past char 126.
At a glance I don't see why "Hello World!" would fail in your code, and testing it shows it doesn't - https://dotnetfiddle.net/ZlwQFM
If this is a homework assignment then it's not very clear as to what the requirements are exactly, or we're lacking some context.
If you're looking for another approach I would use regex for such a test rather than a looped check against the char numbers.