471,337 Members | 1,151 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Which function can do it?

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?
Dec 6 '05 #1
3 1413
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

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
ABC
Thanks

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.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(arrayvalue, number);
if (index < 0 || index >= arraystring.Length) return null;

return arraystring[index];
}

Thi

Dec 6 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mike Darrett | last post: by
3 posts views Thread by Phil Stanton | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.