Multidimensional vs Jagged array

前端 未结 2 1682
醉话见心
醉话见心 2021-01-20 02:43

I have used a MultiDimesional Array as follows

  string[,] Columns = { { \"clientA\", \"clientB\" }}

    if (Columns.Length != 0)
            {
                     


        
2条回答
  •  萌比男神i
    2021-01-20 03:39

    A jagged array is an array of arrays, so you change your definition to:

    string[][] Columns = { new string[] { "clientA", "clientB" }};
    

    Change array access from...

    var value = Columns[0,0];
    

    ...to...

    var value = Columns[0][0];
    

    You also have the option to suppress the warning (right-click on it and select the option you need). According to MSDN, this is a warning that is safe to suppress in certain cases. Check if yours is such a case before you change the code.

提交回复
热议问题