
首先,设置要比较的两个数组 -
// two arrays
int[] arr = new int[] { 99, 87, 56, 45};
int[] brr = new int[] { 99, 87, 56, 45 };现在,使用 SequenceEqual() 比较两个数组 -
arr.SequenceEqual(brr);
以下是比较两个数组的代码 -
using System;
using System.Linq;
namespace Demo {
class Program {
static void Main(string[] args) {
// two arrays
int[] arr = new int[] { 99, 87, 56, 45};
int[] brr = new int[] { 99, 87, 56, 45 };
// compare
Console.WriteLine(arr.SequenceEqual(brr));
}
}
}以上就是C#中如何比较两个数组?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号