C# 有没有类似于matlab的cell的数据容器?

变量里要赋值一些字符串,但是不是简单的 List<string> 或者 string[],而是有一定的层级结构
以前用matlab的时候很方便,在matlab里面,我像这样用cell数组就行了:
strs = {'a', 'b', {'c1', 'c2'}, 'd'};
这个strs就是一个1×4维的cell类型变量。

请问在C#,(或者叫.Net?,我一直搞不清C#和.Net的关系)里面怎么实现类似cell的这种类型?
我一个朋友让我用json
1)请问有更简单的实现吗?
2)如果用json就是最简单的办法,有简单的示例代码吗?比如怎么索引赋值。

根据你的意思我想出两种
一种是类的嵌套

class MyClass
{
    public string Value1;
    public string Value2;

    public MyClass(string value1, string value2)
    {
        Value1 = value1;
        Value2 = value2;
    }
}

class MyClass1
{
    public string Value1;
    public string Value2;
    public MyClass MyClass;

    public MyClass1(string value1,string value2,MyClass myClass)
    {
        Value1 = value1;
        Value2 = value2;
        MyClass = myClass;
    }
}

另一种就是类型的嵌套

Dictionary<string, List<Dictionary<string,string>>> dic;

或者直接List,ArrayList,但这两个读取很烦又耗性能所以不太用

  1. MATLAB对应C#的数据类型主要在引入的父类库MWArray当中。有如下对应规则
    .NET TYPE      MWArrayTYPE    MATLAB Type
    System.Double     MWNumericArray    double
    System.Number    MWNumericArray    double
    System.Float     MWNumericArray     single
    System.Byte      MwNumbericArray    int8
    System.Short     MWNumbericArray    int16
    System.int32      MWNumbericArray    int32
    system.int64      MWNumbericArray    int64
    System.Char     MWCharArray     char
    System.String     MWCharArray     char
    System.Boolean    MWLogicArray     logical
    N/A          MWStructArray     structure
    N/A          MWCellArray     cell

所以说,没有类似的数据容器,具体可以参考下这个

抱歉,两位,MWArray对我来说不太友好,超出当前我的研究能力范围; 嵌套类需要把数据格式写死,不灵活了。
~
我自己研究(百度)一下,可能ArrayList更符合我本来的需求。我写了一个简单的测试代码:
__

static void Main(string[] args)
        {
            ArrayList list = new ArrayList();
            list.Add("a");
            list.Add("b");
            list.Add(new ArrayList() { "c1", "c2" });
            list.Add("d");
            for (int i = 0; i < list.Count; i++)
            {
                if (typeof(System.Collections.ArrayList) == list[i].GetType())
                {
                    for (int j=0; j<(((ArrayList)list[i]).Count); j++)
                    {
                        Console.Write(" ");
                        Console.Write(((ArrayList)(list[i]))[j]);
                    }
                    Console.WriteLine();
                }
                else
                    Console.WriteLine(list[i]);
            }
            Console.ReadKey();
        }
```c#
matlab里面的cell类型,它是一个动态的数组,里面可以存任何东西,这两点其实才是我想要的。