list to search two ways

  • Thread starter Thread starter DraguVaso
  • Start date Start date
D

DraguVaso

Hi,

I need to create a list a litle bit like this:

1 = q
2 = t
3 = z
4 = u
.....

But I need to have it in such a way that I can find easily the letter for a
given number, but also find easily the number for a given letter.

Is there a structure liek this in VB.NET? Or should I make it myself with a
DataView and a filter?

Thanks,

Pieter
 
Hi Pieter,

Well, there might be classes that are better suitable, but you could
easily do that using a char array. You would need a simple search to
obtain the number for a given character though.
 
The problem is too trivial to make much sense.

What are you not telling us?

(note: for an indexed search, you can use a simple lookup array to mirror
the character array, in inverse.
For example, if MyArray(MyIndex) == MyChar

then you would have another array

int MyNewIndex = (int) MyChar;
MyMirrorArray(MyNewIndex) == MyIndex

Does this make sense to you?
--- Nick
 
Thanks both for the answers.
Although I found a solution like this:

I used the SortedList:

With the SortedList.ContainsKey(number) and the SortedList.Item(number) I
could get the corresponding letter...
With the SortedList.containsValue(letter) and the
SortedList.GetKey(SortedList.IndexOfValue(letter)) I could get the number...

Pieter
 
Back
Top