Simplest approach to string-based look-up table

  • Thread starter Thread starter John Dann
  • Start date Start date
J

John Dann

I'm struggling to think of how best to make a lookup table for strings
that's robust to maintain.

What I mean is that when my program encounters string1, it can for
example easily substitute string2, where string1, string2 belong to a
set of pairs of arbitrary string values.

I could set up two separate string arrays ar1() and ar2() and use
something like:

string1 = ar2(getindexof.(ar1,"string1")) ' ??syntax

But then I need to maintain two separate arrays with sets of values
that will almost certainly vary with time, which gives some scope for
error.

This must be a fairly common problem, presumably with a more elegant
answer?

JGD
 
John Dann said:
I'm struggling to think of how best to make a lookup table for strings
that's robust to maintain.

What I mean is that when my program encounters string1, it can for
example easily substitute string2, where string1, string2 belong to a
set of pairs of arbitrary string values.

I could set up two separate string arrays ar1() and ar2() and use
something like:

string1 = ar2(getindexof.(ar1,"string1")) ' ??syntax

But then I need to maintain two separate arrays with sets of values
that will almost certainly vary with time, which gives some scope for
error.

This must be a fairly common problem, presumably with a more elegant
answer?

Check out

System.Collections.Hashtable

David
 
Back
Top