是二维列出了可能出现在C#中? [英] Are 2 dimensional Lists possible in c#?

查看:71
本文介绍了是二维列出了可能出现在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个多维的列表。
作为参考,我工作的一个播放列表分析。

I'd like to set up a multidimensional list. For reference, I am working on a playlist analyzer.

我有一个文件/文件列表,这我的程序标准列表保存。从各列表项文件的一行。

I have a file/file-list, which my program saves in a standard list. One line from the file in each list entry.

我再分析与常规-EX pressions列表中查找特定行。
有些数据/需要被放入一个新的多维名单从线的结果;因为我不知道我会多少结果/数据结了,我不能用一个多维数组。

I then analyze the list with regular-expressions to find specific lines. Some of the data/results from the lines needs to be put into a new multidimensional list; since I don't know how many results/data I'll end up with, I can't use a multidimensional array.

下面是我要插入的数据:

Here is the data I want to insert:


List
(
    [0] => List
        (
            [0] => Track ID
            [1] => Name
            [2] => Artist
            [3] => Album
            [4] => Play Count
            [5] => Skip Count

        )
    [1] => List
        (
And so on....

真实例子:


List
(
    [0] => List
        (
            [0] => 2349
            [1] => The Prime Time of Your Life
            [2] => Daft Punk
            [3] => Human After All
            [4] => 3
            [5] => 2

        )
    [1] => List
        (

所以,是的,mlist [0] [0]将歌曲从1得到的TrackID,mlist [1] [0]歌曲2等。

So yeah, mlist[0][0] would get TrackID from song 1, mlist[1][0] from song 2 etc.

但我有创造一个多维列表巨大的问题。
到目前为止,我想出了

But I am having huge issues creating a multidimensional list. So far I have come up with

List<List<string>> matrix = new List<List<string>>();

但我还没有真正有更大进步:(

But I haven't really had much more progress :(

推荐答案

那么你肯定的可以的使用列表&LT;名单&LT;串&GT;&GT; 在这里你会接着写:

Well you certainly can use a List<List<string>> where you'd then write:

List<string> track = new List<string>();
track.Add("2349");
track.Add("The Prime Time of Your Life");
// etc
matrix.Add(track);

但是,为什么要这么做,而不是建立自己的类来重新present轨道,以轨道ID,名称,艺术家,专辑,播放次数和跳过计数属性?然后,只需有一个列表与LT;跟踪方式&gt;

这篇关于是二维列出了可能出现在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆