C# 如何检查数组列表中是否存在数组

原文:https://www.coder.work/article/2958674

列表:

一个数组列表,想检查一个确切的数组是否在列表中

cs 复制代码
List<int[]> Output = new List<int[]>();

有一个数组

cs 复制代码
int[] coordinates 

想检查coordinates 数组是否在Output 列表中?
最佳答案
使用SequenceEqual

cs 复制代码
bool result = Output.Any(a => a.SequenceEqual(coordinates));

字典获取:

cs 复制代码
    Dictionary<int[], string[]> testDic = new Dictionary<int[], string[]>();
    int[] t = { 1, 2 };
    //找到key
    int[] key = testDic.Keys.Where(x => x.SequenceEqual(t)).FirstOrDefault();
    if (key != null)
    { 
        //对应的value
        string[] value_Instruction = testDic[key];
    }
相关推荐
hez20104 小时前
TypedSql:在 C# 类型系统上实现一个 SQL 查询引擎
c#·.net·.net core·compiler
胡萝卜3.05 小时前
掌握C++ map:高效键值对操作指南
开发语言·数据结构·c++·人工智能·map
电子_咸鱼5 小时前
【STL string 全解析:接口详解、测试实战与模拟实现】
开发语言·c++·vscode·python·算法·leetcode
世洋Blog6 小时前
利用<<左移运算符优雅的设计游戏能力的任意组合和判断
游戏·unity·c#
沐知全栈开发6 小时前
ionic 选项卡栏操作详解
开发语言
曹牧6 小时前
C#中,#region和#endregion
开发语言·c#
顾安r6 小时前
11.22 脚本打包APP 排错指南
linux·服务器·开发语言·前端·flask
czhc11400756636 小时前
c# 1121 构造方法
java·javascript·c#
蒙小萌19937 小时前
Swift UIKit MVVM + RxSwift Development Rules
开发语言·prompt·swift·rxswift
Z***25807 小时前
Java爬虫框架
java·开发语言·爬虫