开发者

Correlating parallel arrays in C#

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜