types of arrays in C# ...?
types of arrays in C# ...?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nipun TomarPosted Dec 20, 2013, 2:26 AM
Read this article, here you find a clear and simple explanation:
http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingWithArrays11232005064036AM/WorkingWithArrays.aspx
Thanks
Sandeep Singh ShekhawatPosted Dec 20, 2013, 2:18 AM
Single-dimensional arrays:
int[] numbers = new int[5];Multidimensional arrays:
string[,] names = new string[5,4];Array-of-arrays (jagged):
byte[][] scores = new byte[5][];for (int x = 0; x < scores.Length; x++){scores[x] = new byte[4];}You can also have larger arrays. For example, you can have a three-dimensional rectangular array:
int[,,] buttons = new int[4,5,3];You can even mix rectangular and jagged arrays. For example, the following code declares a single-dimensional array of three-dimensional arrays of two-dimensional arrays of type int:
int[][,,][,] numbers;// arrays.cs
using System;
class DeclareArraysSample
{
public static void Main()
{
// Single-dimensional array
int[] numbers = new int[5];
// Multidimensional array
string[,] names = new string[5,4];
// Array-of-arrays (jagged array)
byte[][] scores = new byte[5][];
// Create the jagged array
for (int i = 0; i < scores.Length; i++)
{
scores[i] = new byte[i+3];
}
// Print length of each row
for (int i = 0; i < scores.Length; i++)
{
Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length);
}
Console.ReadKey();
}
}
OUTPUTJignesh TrivediPosted Dec 20, 2013, 1:34 AM
hi,
I thing Array is simple collection of data of same type... there is no such specific type of array.
yes it might be one or Multi-dimensional arrays
please refer
http://www.tutorialspoint.com/csharp/csharp_arrays.htm
http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx
hope this will help you.
Satyapriya NayakPosted Dec 20, 2013, 1:10 AM