以最少的循环把两个数组里面的相同结果输出来

要求:有两个数组一个N 个元素,另一个M 个元素,这两个数组中有些元素是相同的,希
望通过编写一段程序将两个数组中的相同元素找出来,请用最少的循环次数完成需求,请问
需要用什么方法?

    1. string[] str1 = { "1", "2", "3", "4", "5", "6" };  
    2.         string[] str2= { "11", "23", "3", "4", "55", "66" };  
    3.   
    4.         ArrayList list1 = ArrayList.Adapter(str1);  
    5.         ArrayList list2 = ArrayList.Adapter(str2);  
    6.         for (int i = 0; i < list1.Count; i++)  
    7.         {  
    8.             if (list2.Contains(list1[i]))  
    9.             {  
    10.                 Response.Write(list1[i].ToString());  
    11.             }  
    12.         }  
原文地址:https://www.cnblogs.com/doudouxiaoye/p/5697625.html