C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

What are Jagged Arrays in C#?


Posted Date: 21 Mar 2007    Resource Type: Articles    Category: .NET Framework
Author: Thiru BalajeMember Level: Silver    
Rating: 1 out of 5Points: 6



Jagged Arrays





A Jagged Array is an array of an array in which the length of each array index can differ.
Example: A Jagged Array can be used is to create a table in which the lengths of the rows are not same. This Array is declared using square brackets ( [ ] ) to indicate each dimension.




The following code demonstrates the creation of a two-dimensional jagged array.

Class Jagged
{
public static void Main()
{
int [][] jagged=new int [3][];
jagged[0]=mew int[4]
jagged[1]=mew int[3]
jagged[2]=mew int[5]
int I;
‘Storing values in first array
for (I=0;I<4;I++)
jagged[0][I]=I;
‘Storing values in second array

for( I=0;I<3;I++)
jagged[1][I]=I;
‘Storing values in third array

for(I=0;I<5;I++)
jagged[2][I]=I;
‘Displaying values from first array

for (I=0;I<4;I++)
Console.WriteLine(jagged[0][I])
‘Displaying values from second array

for (I=0;I<3;I++)
Console.WriteLine(jagged[1][I])

‘Displaying values from third array
for(I=0;I<5;I++)
Console.WriteLine(jagged[2][I])

}
}




Run the code to see the output.







Responses

Author: malaikani rajamani    30 Jan 2009Member Level: Bronze   Points : 0
nice and simple


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Jagged array  .  Code  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Read data asynchronously as XML using SqlCommand Object
Previous Resource: Implementing SQL Server 2005 Query Notifications in C# Windows Application
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use