日期:2014-05-18 浏览次数:20462 次
string[] A = new string[] { "朱雅君", "姚怡尔", "涂静" }; string[] B = new string[] { "姚怡尔", "涂静", "刘刚" }; var re = (from a in A select a).Intersect(from b in B select b).ToArray();
------解决方案--------------------
string[] A = new string[]{"朱雅君","姚怡尔","涂静"}; string[] B = new string[]{"姚怡尔","涂静","刘刚"}; var vs = from s in A where B.Contains(s) select s; foreach (var v in vs) { MessageBox.Show(v.ToString()); }
------解决方案--------------------
linq就是好用。。简单又清晰
------解决方案--------------------
string[] A = {"朱雅君","姚怡尔","涂静"}; string[] B = {"姚怡尔","涂静","刘刚"}; foreach (var item in A) { foreach (var item2 in B) { if (item == item2) return item2; } }