Ragged and Jagged Arrays

前端 未结 4 1817
情书的邮戳
情书的邮戳 2021-02-07 12:42

What is the difference between ragged and jagged arrays? As per my research both have the same definitions, i.e. two-dimensional arrays with different column lengths.

4条回答
  •  盖世英雄少女心
    2021-02-07 13:42

    Ragged array: is an array with more than one dimension each dimension has different size

    ex:

    10 20 30
    11 22 22 33 44
    77 88
    

    Jagged array: an array where each item in the array is another array. C# Code:

    int[][] jaggedArray = new int[3][];
    jaggedArray[0] = new int[5];
    jaggedArray[1] = new int[4];
    jaggedArray[2] = new int[2];
    

提交回复
热议问题