c# – 是否有类似List(多维通用列表)的东西

栏目: C# · 发布时间: 6年前

内容简介:我需要类似于List<String,Int32,Int32>的东西. List一次只支持一种类型,而Dictionary一次只支持两种类型.是否有一种干净的方式来做上面的事情(一个多维通用列表/集合)?翻译自:https://stackoverflow.com/questions/2994811/is-there-something-like-liststring-int32-int32-multidimensional-generic-lis

我需要类似于List<String,Int32,Int32>的东西. List一次只支持一种类型,而Dictionary一次只支持两种类型.是否有一种干净的方式来做上面的事情(一个多维通用列表/集合)?

最好的方法是为它创建一个容器,即一个类

public class Container
{
    public int int1 { get; set; }
    public int int2 { get; set; }
    public string string1 { get; set; }
}

然后在你需要它的代码中

List<Container> myContainer = new List<Container>();

翻译自:https://stackoverflow.com/questions/2994811/is-there-something-like-liststring-int32-int32-multidimensional-generic-lis


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Natural Language Processing with Python

Natural Language Processing with Python

Steven Bird、Ewan Klein、Edward Loper / O'Reilly Media / 2009-7-10 / USD 44.99

This book offers a highly accessible introduction to Natural Language Processing, the field that underpins a variety of language technologies, ranging from predictive text and email filtering to autom......一起来看看 《Natural Language Processing with Python》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具