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

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

内容简介:我需要类似于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


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

查看所有标签

猜你喜欢:

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

AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and

AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and

George F. Luger、William A Stubblefield / Addison Wesley / 2008-09-04 / USD 22.20

This book is designed for three primary purposes. The first is as a programming language component of a general class in Artificial Intelligence. From this viewpoint, the authors see as essential that......一起来看看 《AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and 》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

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

Markdown 在线编辑器