如何比较 C# 中的数组? [英] How to compare arrays in C#?

查看:16
本文介绍了如何比较 C# 中的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
在 C# 中比较数组的最简单方法

如何在 C# 中比较两个数组?

How can I compare two arrays in C#?

我使用了下面的代码,但它的结果是错误的.我原以为这是真的.

I use the following code, but its result is false. I was expecting it to be true.

Array.Equals(childe1,grandFatherNode);

推荐答案

可以使用System.Linq中的Enumerable.SequenceEqual()比较数组中的内容

You can use the Enumerable.SequenceEqual() in the System.Linq to compare the contents in the array

bool isEqual = Enumerable.SequenceEqual(target1, target2);

这篇关于如何比较 C# 中的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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