I want to check some string for invalid characters. With invalid characters, I mean characters that shouldn't be. What kind of characters are these? It is different, but I think it is not so important, it is important how I should do it, and what is the easiest and best way (performance) for this?
Say I just need strings containing 'A-Z', 'empty', '.', '$', '0-9'
So, if I have a string like " HELLO STACKOVERFLOW " => is invalid, due to 'a'. Ok, how to do this? I could make a List<char> and put in it all char that are not allowed, and check the line with this list. Maybe this is not a good idea, because there are a lot of characters. But could I make a list containing all valid characters? And then? For each char in a string, do I need to compare List<char> ? Any smart code for this? And one more question: if I added AZ to the List<char> , I need to add 25 characters manually, but these characters, as I know, are 65-90 in the ASCII table, can I add them more easily? Any suggestions? Thanks you
silla
source share