如何匹配2个数组ironpython或c#

时间:2011-02-19 08:57:37

标签: c# ironpython

  

可能重复:
  How to match two arrays

我有2个阵列

<=> A = [好,坏,猫,青蛙]

B = [最好的,伟大的,生病的,邪恶的,邪恶的,腐烂的,恶毒的,贫穷的,讨厌的,粪便,蟾蜍,围场)

我希望在两个数组之间进行匹配

结果
[good:best,great]
[坏:生病,邪恶,邪恶,腐烂,恶毒,贫穷,讨厌] [猫:puss]
[青蛙:蟾蜍,围场]

1 个答案:

答案 0 :(得分:0)

试试这个,

string[] roles = {"a", "e", "f", "h"};
string[] allRoles = {"a", "b", "c", "d", "e", "f", "g", "h", "i"};

foreach (string nextRole in allRoles) {
    if(Array.IndexOf(roles, nextRole) != -1)
    {
        Response.Write(nextRole + "<br/>");
    }
}