最简单的比较C#数组方式 [英] Easiest way to compare arrays in C#
本文介绍了最简单的比较C#数组方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java中,满足Arrays.equals()可以非常方便地比较两个基本数组的内容(重载可用于所有的基本类型)。
In Java, Arrays.equals() allows to easily compare the content of two basic arrays (overloads are available for all the basic types).
有没有在C#这样的事情?有没有比较两个数组的内容在C#中的任何神奇的方式?
Is there such a thing in C#? Is there any "magic" way of comparing the content of two arrays in C#?
推荐答案
您可以使用 SequenceEqual 。这适用于任何的IEnumerable< T>
,不只是数组。
You could use SequenceEqual. This works for any IEnumerable<T>
, not just arrays.
这篇关于最简单的比较C#数组方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文