C# Corner
Tech
News
Videos
Forums
Trainings
Books
Live
More
Interviews
Events
Jobs
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Jagged Arrays in C#
WhatsApp
ANIL KUMAR GUPTA
10y
4.4
k
0
0
25
Blog
Definitions
Arrays which have more than one dimension; these arrays-of-arrays are called multidimensional arrays. They are very similar to standard arrays with the exception that they have multiple sets of square brackets after the array variable.
step
Go to Solution explorer and open console project.
Add new class.
using
System;
public
class
JaggedArray
{
static
void
Main()
{
int
[][] jaggedArr =
new
int
[][]
{
new
int
[]
{
1,2
},
new
int
[]
{
1,2,3
},
new
int
[]
{
1,2,3,4
}
};
foreach
(
int
[] array
in
jaggedArr)
{
foreach
(
int
e
in
array)
{
Console.Write(e +
" "
);
}
}
Console.Write(
'\n'
);
}
}
Console.WriteLine(array[0, 1]);
Console.WriteLine(array[1, 0]);
Console.WriteLine(array[1, 1]);
Console.ReadLine();
}
}
People also reading
Membership not found