.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Syntax for Jagged Array

Posted By: PankajGupta     Posted Date: July 22, 2009    Points:2   Category :C#
What is the Syntax for Jagged Array? Thanks

Responses
Author: Akhil Raj       [Moderator]      
Posted Date: July 22, 2009     Points: 5   

please check the following sample..


using System;
public class MyArrayc2
{
public static void Main()
{
int [][]arr=new int[4][];
arr[0]=new int[3];
arr[1]=new int[2];
arr[2]=new int[5];
arr[3]=new int[4];

Console.WriteLine("Enter the numbers for Jagged Array");

for(int i=0 ; i < arr.Length ; i++)
{
for(int x=0 ; x < arr[i].Length ; x++)
{
String st= Console.ReadLine();
int num=Int32.Parse(st);
arr[i][x]=num;
}
}

Console.WriteLine("");
Console.WriteLine("Printing the Elemnts");

for(int x=0 ; x < arr.Length ; x++)
{
for(int y=0 ; y < arr[x].Length ; y++)
{
Console.Write(arr[x][y]);
Console.Write("\0");
}
Console.WriteLine("");
}
}
}

Author: Syed Shakeer Hussain             
Posted Date: July 22, 2009     Points: 5   

Hi Gupta

check the following link for more information about jagged arrays
http://msdn.microsoft.com/en-us/library/2s05feca(VS.80).aspx



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend