How jagged array can be initialized using indexer?

1 answer

Answer

1069591

2026-03-03 00:00

+ Follow

A jagged array, which is an array of arrays, can be initialized using indexers in C# by first declaring the array and then specifying the size of each sub-array. For example, you can create a jagged array like this: int[][] jaggedArray = new int[3][];, and then initialize each sub-array individually, such as jaggedArray[0] = new int[2]; and jaggedArray[1] = new int[3];. You can also initialize it inline, like int[][] jaggedArray = new int[][] { new int[2], new int[3], new int[1] };. This allows for flexible sizing of each inner array.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.