How can I associate two unidentical( arrays of different typ开发者_JS百科es) string arrays using C#?
int lenght = 3;
string[] arr1 = new string [length] { "one", "two", "three", };
int[] arr2 = new int [length] { 1, 2, 3, };
string search = "two";
for (a = 0; a < lenght; a++)
{
if (arr1[a] == search)
Console.WriteLine("Element found at position {0}. The corresponding element is {1}", a + 1, arr2[a]);
}
I'm not sure if this is what you mean or not but you are better off using two dimensional arrays if you want rows and columns.
精彩评论