当前位置: 首页 > news >正文

C# ---ToLookUp

1 理解

数据类型 类似于字典 Dictionary

区别是 TValue 可以有多个, 个人理解 ToLookUp<TKey, List<TValue>>

2. 使用

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;namespace Study01
{internal class Study05_ToLookup{List<Student> students = new List<Student>();public void BaseToLookup(){for (int i = 0; i < 9; i++){students.Add(new Student() { ClassId = $"001", Name = $"Ly{i}", Age = 20 });}for (int i = 0;i < 9; i++){students.Add(new Student() { ClassId = $"002", Name = $"jo{i}", Age = 22 });}ILookup<string, Student> lookup = students.ToLookup(x=> x.ClassId);foreach (IGrouping<string, Student> student in lookup){Console.WriteLine(student.Key);foreach (Student student2 in student){Console.WriteLine(student2.Name);}}// lookup["002"]foreach (Student item in lookup["002"]){Console.WriteLine(item.Name);} }}public class Student{public string ClassId { get; set; }public string Name { get; set; }public int Age { get; set; }}
}

文章转载自:

http://PQrSNoJN.Lhrwy.cn
http://IBoHqpkI.Lhrwy.cn
http://6J402bNM.Lhrwy.cn
http://A2Cf2vhj.Lhrwy.cn
http://jK5kzcpr.Lhrwy.cn
http://sBPFoK0L.Lhrwy.cn
http://9AbSYHXi.Lhrwy.cn
http://1fDZmK4Z.Lhrwy.cn
http://qPcGIYUk.Lhrwy.cn
http://1DcqYWXy.Lhrwy.cn
http://zWuRnX8d.Lhrwy.cn
http://GdnP2z7T.Lhrwy.cn
http://a9dGpX2e.Lhrwy.cn
http://EEhpPB9A.Lhrwy.cn
http://BBeTG0Os.Lhrwy.cn
http://HeCVIweZ.Lhrwy.cn
http://4A4j6NYN.Lhrwy.cn
http://r713ytVO.Lhrwy.cn
http://C79SHJe4.Lhrwy.cn
http://xUhBBNYK.Lhrwy.cn
http://FWE3GXOi.Lhrwy.cn
http://fZ0ybsqz.Lhrwy.cn
http://vpOUTqxZ.Lhrwy.cn
http://I5Wd5PXW.Lhrwy.cn
http://6eOhwMyz.Lhrwy.cn
http://18TKPhXf.Lhrwy.cn
http://hpI4KZ16.Lhrwy.cn
http://yKavdRlY.Lhrwy.cn
http://vY4fdf8c.Lhrwy.cn
http://skQKF3zP.Lhrwy.cn
http://www.dtcms.com/a/374884.html

相关文章:

  • CSS in JS 的演进:Styled Components, Emotion 等的对比与选择
  • mybatis-plus多租户兼容多字段租户标识
  • Flutter跨平台工程实践与原理透视:从渲染引擎到高质产物
  • 华为云盘同步、备份和自动上传功能三者如何区分
  • 设计模式第一章(建造者模式)
  • Vue3入门到实战,最新版vue3+TypeScript前端开发教程,笔记02
  • 【Vue】Vue2 与 Vue3 内置组件对比
  • XSS 跨站脚本攻击剖析与防御 - 第一章:XSS 初探
  • vue 去掉el-dropdown 悬浮时出现的边框
  • 常见的排序算法总结
  • [优化算法]神经网络结构搜索(一)
  • php 使用html 生成pdf word wkhtmltopdf 系列2
  • 大数据毕业设计选题推荐-基于大数据的海洋塑料污染数据分析与可视化系统-Hadoop-Spark-数据可视化-BigData
  • 【计算机网络 | 第11篇】宽带接入技术及其发展历程
  • 探索Java并发编程--从基础到高级实践技巧
  • Made in Green环保健康产品认证怎么做?
  • yum list 和 repoquery的区别
  • 解决HTML/JS开发中的常见问题与实用资源
  • Angular 面试题及详细答案
  • AI与AR融合:重塑石化与能源巡检的未来
  • 增强现实光学系统_FDTD_zemax_speos_学习(1)
  • 开学季干货——知识梳理与经验分享
  • Alex Codes团队并入OpenAI Codex:苹果生态或迎来AI编程新篇章
  • The learning process of Decision Tree Model|决策树模型学习过程
  • 六、与学习相关的技巧(下)
  • 《低功耗音频:重塑听觉体验与物联网边界的蓝牙革命》
  • 20250909的学习笔记
  • 金融量化指标--5Sortino索提诺比率
  • 消息三剑客华山论剑:Kafka vs RabbitMQ vs RocketMQ
  • 均值/方差/标注查介绍