Simplest approach to string-based look-up table

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
 
D

David Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top