473,728 Members | 1,909 Online

# Which function can do it?

Is there any function to as:

arrayvalue = {0, 2, 4, 6, 7, 8}
arraystring = {"Zero", "Two", "Four", "Six", "More1", "More2"}

If the parameter value is 6, the function return "More1".

Which function can do it?
Dec 6 '05 #1
3 1471
Did you mean: If the parameter value is 6, the function return "Six"?

If the values of arrayvalue are not dupplicate, you can try this:

string GetString(int number)
{
int index = Array.IndexOf(a rrayvalue, number);
if (index < 0 || index >= arraystring.Len gth) return null;

return arraystring[index];
}

Thi

Dec 6 '05 #2
ABC wrote:
Is there any function to as:

arrayvalue = {0, 2, 4, 6, 7, 8}
arraystring = {"Zero", "Two", "Four", "Six", "More1", "More2"}

If the parameter value is 6, the function return "More1".

Which function can do it?

I think it is better to use a hashtable or some sort collection that is
dereived from IDictionary
(http://msdn.microsoft.com/library/de...classtopic.asp)

it fits more you needs I think (I am not quit sure because I am missing
the context)

Dec 6 '05 #3
Thanks

"Truong Hong Thi" <th*****@gmail. com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Did you mean: If the parameter value is 6, the function return "Six"?

If the values of arrayvalue are not dupplicate, you can try this:

string GetString(int number)
{
int index = Array.IndexOf(a rrayvalue, number);
if (index < 0 || index >= arraystring.Len gth) return null;

return arraystring[index];
}

Thi

Dec 6 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.