如何比较两个List< String>在C#中使用LINQ [英] How to compare two List<String> using LINQ in C#

查看:68
本文介绍了如何比较两个List< String>在C#中使用LINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个列表就像

          LISTONE    "ONE", "TWO", "THREE"
          LISTTWO    "ONE", "TWO", "THREE"

我需要比较两个列表中的项目是否顺序相同.

i need to compare the whether the items in two lists are in same order or not.

在LINQ中有什么方法可以做到吗

Is there any way to do this in LINQ

推荐答案

也许:

bool equal = collection1.SequenceEqual(collection2);

另请参见:比较两个集合是否相等,无论它们中的项顺序如何

这篇关于如何比较两个List< String>在C#中使用LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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