You need to look at using a data structure like a Trie[^], or as was already pointed out Patrcia Trie[^]. The Wikipedia articles should give you enough information to get started on an actual implementation.
Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai