One Dimensional Array in C#
In this chapter you will learn:
What is single dimensional array?
How to declare one dimensional array?
How to use single dimensional array in C# programming?
The one dimensional array or single dimensional array in C# is the simplest type of array that contains only one row for storing data. It has single set of square bracket (“”). To declare single dimensional array in C#, you can write the following code.
int age=new int;
The array age is a one dimensional array that contains only 6 elements in a single row.
Programming Example of One Dimensional Array:
Programming Example of Declaration and Initialization of Array:
static void Main(string args)
//Declaring single dimensional array
string Books = new string;
Books = "C#";
Books = "Java";
Books = "VB.NET";
Books = "C++";
Books = "C";
Console.WriteLine("All the element of Books array is:\n\n");
int i = 0;
for (i = 0; i < 5; i++)
All the element of Books array is:
1 2 3 4 5
C# Java VB.NET C++ C
In this chapter you learned about single dimensional array in C#. You also learned how to store value and access value from single dimensional array. In next chapter you will learn about multi dimensional array in C#.