i have 2 arrays

controllerlist[11] and taglist[5]

i need to compare them so that i can find any elements that match, is there a way of doing it instead of nested for loops?

Recommended Answers

All 2 Replies

perhaps you could do it with one for less by using the Contains method:

int[] a = new int[4] { 1, 2, 3, 4 };
            int[] b = new int[3] { 5, 6, 3 };
            bool c = a.Contains(b[2]);

The boolean c should be true here because b[2]=3 and a contains 3.

Sort them individually, then with one loop interleave them while comparing them for matches.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.