I can't get my list to store array variables (error CS0022)

Assets/Scripts/MyListClass.cs(10,28): error CS0022: Wrong number of indexes 1' inside [ ], expected 2’

I wanna add an array string variable to a list. From some reason I get the error above. Does anyone know why? And how do I fix it?

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MyArrayClass : MonoBehaviour {
    public string[,] myarray = new string[,]
    {
        {
            "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "bb",
            "cc",
            "dd",
            "ee"
        },
        {
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "gg",
            "hh",
            "ii",
            "jj"
        }
    };
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MyListClass : MyArrayClass {
    public List<string> mylist = new List<string>();
    public string MyString;
    // Use this for initialization
    void Start () {
        MyString = myarray[0][0];
        mylist.Add (MyString);
        Debug.Log (mylist);
    }
}

To get value from 2D array, you need to have 2 indexes:

value = myarray[0,0];

There is a difference between

string[,]

and

string[][]

The first is a two dimensional array and is accessed like

myarray[0,0]

The second is an array of arrays and is accessed like

myarray[0][0]

Thank you, my bad, I’m used to PHP :slight_smile: