C# 给List编个序号

给List编个号

csharp 复制代码
 int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
 int i = 0;
 var q = (from n in numbers
          select (index:++i,number:n))
          .ToList();

foreach (var v in q)
{
     Console.WriteLine($"i = {v.index}, v = {v.number}");
}           
相关推荐
一只鹿鹿鹿2 小时前
智慧水利一体化建设方案
大数据·运维·开发语言·数据库·物联网
没有医保李先生3 小时前
字节对齐的总结
java·开发语言
Elastic 中国社区官方博客4 小时前
使用 Elastic 进行网络监控:统一网络可观测性
大数据·开发语言·网络·人工智能·elasticsearch·搜索引擎·全文检索
Codefengfeng4 小时前
Python Base环境中加包的方法
开发语言·python
清水白石0084 小时前
《Python 编程全景解析:从核心精要到测试替身(Test Doubles)五大武器的实战淬炼》
开发语言·python
六件套是我5 小时前
无法访问org.springframeword.beans.factory.annotation.Value
java·开发语言·spring boot
S-码农5 小时前
Linux ——条件变量
linux·开发语言
清水白石0085 小时前
《Python 编程全景解析:从核心精要到 Hypothesis 属性基测试的边界探索》
开发语言·python
IT枫斗者6 小时前
IntelliJ IDEA 2025.3史诗级更新:统一发行版+Spring Boot 4支持,这更新太香了!
java·开发语言·前端·javascript·spring boot·后端·intellij-idea