what an array is?
The dictionary meaning of array is an orderly arrangement or sequential arrangement of elements.
In computer science term:
An array is a data structure that contains a number of variables, which are accessed through computed indices. The variables contained in an array, also called the elements of the array, are all of the same type, and this type is called the element type of the array.
An array has a rank that determines the number of indices associated with each array element. The rank of an array is also referred to as the dimensions of the array. An array with a rank of one is called a single-dimensional array. An array with a rank greater than one is called a multi-dimensional array. Specific sized multidimensional arrays are often referred to as two-dimensional arrays, three-dimensional arrays, and so on.
What are jagged arrays?
A jagged array is an array whose elements are arrays. The elements of jagged array can be of different dimensions and sizes. A jagged array is sometimes called as "array-of-arrays". It is called jagged because each of its rows is of different size so the final or graphical representation is not a square.
When you create a jagged array you declare the number of rows in your array. Each row will hold an array that will be on any length. Before filling the values in the inner arrays you must declare them.
Jagged array declaration in C#:
For e.g. : int [] [] myJaggedArray = new int [3][];
Declaration of inner arrays:
myJaggedArray[0] = new int[5] ; // First inner array will be of length 5.
myJaggedArray[1] = new int[4] ; // Second inner array will be of length 4.
myJaggedArray[2] = new int[3] ; // Third inner array will be of length 3.
Now to access third element of second row we write:
int value = myJaggedArray[1][2];
Note that while declaring the array the second dimension is not supplied because this you will declare later on in the code.
Jagged array are created out of single dimensional arrays so be careful while using them. Don't confuse it with multi-dimensional arrays because unlike them jagged arrays are not rectangular arrays.
For more information on arrays:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfarrayspg.asp
Wednesday, July 16, 2008
Subscribe to:
Post Comments (Atom)
Archives
-
▼
2008
(201)
-
▼
July
(64)
- Acronyms in .NET
- Short Answer .NET Interview Questions (PAGE 5)
- Short Answer .NET Interview Questions (PAGE 4)
- Short Answer .NET Interview Questions (PAGE 3)
- Short Answer .NET Interview Questions (PAGE 2)
- Short Answer .NET Interview Questions (PAGE 1)
- VB.NET Interview Questions 16
- VB.NET Interview Questions 15
- VB.NET Interview Questions 14
- VB.NET Interview Questions 13
- VB.NET Interview Questions 12
- VB.NET Interview Questions 11
- VB.NET Interview Questions
- VB.NET Interview Questions 9
- VB.NET Interview Questions 8
- VB.NET Interview Questions 6
- VB.NET Interview Questions 5
- VB.NET Interview Questions 4
- VB.NET Interview Questions 3
- VB.NET Interview Questions 2
- VB.NET Interview Questions 1
- ASP.NET 2.0Interview Questions see
- Tough ASP.NET interview questions all see
- ASP.NET INTERVIEW QUESTIONS 16
- dot see it
- dot net free interview questions see
- General C# Interview Questions :
- C# Interview Questions and Answers 15
- C# Interview Questions and Answers 14
- C# Interview Questions and Answers 13
- C# Interview Questions and Answers 12
- C# Interview Questions and Answers 11
- C# Interview Questions and Answers 10
- C# Interview Questions and Answers 9
- C# Interview Questions and Answers8
- C# Interview Questions and Answers7
- C# Interview Questions and Answers 6
- C# Interview Questions and Answers 5
- C# Interview Questions and Answers 4
- C Interview Questions 3
- C Interview Questions 2
- C Interview Questions
- .Net Web Interview Questions and Answers 5
- .Net Web Interview Questions and Answers 4
- .Net Web Interview Questions and Answers 3
- Which of the following operators has the highest p...
- .Net Web Interview Questions and Answers
- dotnet
- .Net Database Interview Questions 12
- Microsoft .Net Interview Questions 00
- .Net Database Interview Questions and Answers free
- What are different methods of session maintenance ...
- Microsoft .Net Interview Questions and Answers 8
- Microsoft .Net Interview Questions and Answers 2
- Microsoft .Net Interview Questions and Answers
- .Net Interview Questions and Answers 10
- .Net Interview Questions and Answers 8
- .Net Interview Questions and Answers 6
- .Net Interview Questions and Answers 5
- .Net Interview Questions and Answers 4
- .Net Interview Questions and Answers 3
- dot net interview questions 2
- .Net Interview Questions and Answers 1
- Interview questions for .NET
-
▼
July
(64)
No comments:
Post a Comment