开发者

how to match 2 arrays ironpython or c# [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to match two arrays

I have 2 arrays

A = [good开发者_如何学Go, bad, cat, frog]

and

B = [best, great, ill, evil, wicked, rotten, vicious, poor, nasty, puss, toad, paddock]

and I want to match between 2 arrays

Result

[good : best, great]

[bad : ill, evil, wicked, rotten, vicious, poor, nasty]

[cat : puss]

[frog : toad, paddock]


Try this,

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/>");
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜