Which function can do it?

  • Thread starter Thread starter ABC
  • Start date Start date
A

ABC

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?
 
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(arrayvalue, number);
if (index < 0 || index >= arraystring.Length) return null;

return arraystring[index];
}

Thi
 
ABC said:
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/d...lrfsystemcollectionsidictionaryclasstopic.asp)

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