比较两个字符串的ArrayList [英] Compare two string ArrayLists

查看:206
本文介绍了比较两个字符串的ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数组列表

  dim Colors1 = New ArrayList
  Colors1.Add("Blue")
  Colors1.Add("Red")
  Colors1.Add("Yellow")
  Colors1.Add("Green")
  Colors1.Add("Purple")

  dim Colors2 = New ArrayList
  Colors2.Add("Blue")
  Colors2.Add("Green")
  Colors2.Add("Yellow")

我想找出哪些颜色从Colors2了在COLORS1发现失踪

I would like to find out which colors are missing from Colors2 that are found in Colors1

推荐答案

看看使用除了方法。 此方法返回在第一次没有出现在第二那些元件,不还返回在第二,不会出现在第一次的那些元素。

Look at using Except method. "This method returns those elements in first that do not appear in second. It does not also return those elements in second that do not appear in first."

所以,你可以把颜色2作为第一个参数和COLORS1为第二。

So you can just put colors 2 as the first argument and colors1 as the second.

编辑:我的意思是,你可以把颜色1和第2的颜色作为第二

I meant you can put colors 1 first and colors 2 as the second.

EDIT2:(每肖恩)

(per Sean)

var missingFrom2 = colors1.Except(colors2);

这篇关于比较两个字符串的ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆