On Thu, 28 Jun 2007 15:32:01 -0700, Harry V
<Ha****@discussions.microsoft.comwrote:
Is it possible to validate a 2-character substring against a list of 13
2-character codes without a select statement to a table or parsing an
array?
Something like ... myChars in ("aa", "bb", "cc")...
What do mean by "parsing an array"?
You could just put your list of substrings to match in an array, then use
Array.Exists() or Array.IndexOf() to see if the substring is in the
array. There are similar methods you could use with the List<class.
Alternatively, you could probably use the RegEx class to see if there's a
match. I think you can use a search string like "[aa|bb|cc|...]" on your
string; if your string is only two characters long and there's a match,
then you know your substring was one of the items in the RegEx.
Personally, I'd use the array look-up method, but I suppose if you're
really against using an array or List<>, RegEx would do.
Basically, there's any number of ways to do what you want. Without a more
precise problem description, it's hard to offer anything other than very
general advice.
Pete