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];
    }
相关推荐
艾伦_耶格宇1 小时前
【AI】-4 OpenCode Go 接入 Obsidian 完整指南
运维·开发语言·人工智能·agent·opencode
旋生万物1 小时前
【终极实战】用Python从零“生成“一个宇宙:螺旋干涉模型的代码实现
开发语言·前端·人工智能·react.js·php·wpf
16月6日-晴2 小时前
Java面向对象进阶—多态
java·开发语言
冯汉栩2 小时前
Swift Control RollingCountdownView(动画倒计时)
开发语言·ios·swift
lisanmengmeng2 小时前
搭建elk环境并接入frostmourne,实现监控报警效果(五)
开发语言·elk·日志·日志监控
oh,huoyuyan3 小时前
JS 动态网页抓不到?试试火车采集器网页抓取工具
开发语言·javascript·ecmascript
风流 少年3 小时前
hutool
java·服务器·开发语言
一木 之林4 小时前
四、STL容器与数据结构
开发语言·数据结构·c++
QX_hao4 小时前
【Go】--Cobra-cli的用法
开发语言·后端·golang
艾醒(AiXing-w)4 小时前
LangChain 1.0 入门(三):稳定性双核心——重试机制+速率限速器参数详解与实战
开发语言·langchain·php