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")...

Signature
Harry E Vermillion
IT2
Division of Wildlife
State of Colorado
Peter Duniho - 29 Jun 2007 00:52 GMT
> 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
Pramod Anchuparayil - 29 Jun 2007 07:09 GMT
Not sure if I quite understand what you are trying to do but something like
this should work.
string[] twoCharString = { "AA", "BB", "CC", "DD" };
MessageBox.Show((twoCharString.Contains("BB") ? "Yes" :
"Nope"));
You can use the Contains method of a string.
-Pramod Anchuparayil
> 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")...
Harry V - 29 Jun 2007 16:06 GMT
THat should do it. Thank you, sir.

Signature
Harry E Vermillion
IT2
Division of Wildlife
State of Colorado
> Not sure if I quite understand what you are trying to do but something like
> this should work.
[quoted text clipped - 11 lines]
> > array?
> > Something like ... myChars in ("aa", "bb", "cc")...