
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are jagged arrays in C#?
A Jagged array is an array of arrays in C#. You can declare and initialize it −
int[][] rank = new int[1][]{new int[]{5,3,1}};
The following is an example showing how to work with jagged arrays in C# −
Example
using System; namespace Program { class Demo { static void Main(string[] args) { int[][] rank = new int[][]{new int[]{1,2},new int[]{3,4}}; int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("a[{0}][{1}] = {2}", i, j, rank[i][j]); } } Console.ReadKey(); } } }
Output
Above, we have a jagged array of 2 array of integers −
int[][] rank = new int[][]{new int[]{1,2},new int[]{3,4}};
- Related Articles
- What are jagged arrays and explain with an example in Java?
- How to initialize jagged arrays in C#?
- How to define jagged arrays in C#?
- How do you initialize jagged arrays in C#?
- How do you access jagged arrays in C#?
- How do you declare jagged arrays in C#
- How do you declare, initialize and access jagged arrays in C#?
- What are the differences between a multi-dimensional array and jagged array?
- What are dynamic arrays in C#?
- What are mixed arrays in C#?
- What are associative Arrays in JavaScript?
- Jagged Array in Java
- Jagged Array in C#
- What are parameter/param arrays in C#?
- What are two-dimensional arrays in C#?

Advertisements