在 C# 中比较数组的最简单方法 [英] Easiest way to compare arrays in C#

查看:53
本文介绍了在 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#?

推荐答案

您可以使用 Enumerable.SequenceEqual.这适用于任何 IEnumerable,而不仅仅是数组.

You could use Enumerable.SequenceEqual. This works for any IEnumerable<T>, not just arrays.

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

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