Array : It is a set of similar type value that are stored in a sequential order that is in the form of Rows ans Column.
In C Sharp array can be declare as fixed length or dynamically.
Fixed length can store a predefined number of items.While size of dynamic arrays increases as we add new items to the array.
An array is a reference type. So memory is allocated for this on the managed heap memory.
One dimensional Arrays : Storing the data in the form of Row.
Syntax And Examples :
Note : In c# language an array can be initialized only by using a new keyword .
In C Sharp array can be declare as fixed length or dynamically.
Fixed length can store a predefined number of items.While size of dynamic arrays increases as we add new items to the array.
An array is a reference type. So memory is allocated for this on the managed heap memory.
One dimensional Arrays : Storing the data in the form of Row.
Syntax And Examples :
Note : In c# language an array can be initialized only by using a new keyword .
using System; public class Program { public static void Main() { int [] arr = new int[6]; int x =0 ; //Accessing the single dimenson array by for loop for (int i =0 ; i< 6 ; i++) { Console.Write(arr[i]+ " "); } Console.WriteLine(); //Assigning values in single dimenson array using for loop for(int i = 0; i< 6 ; i++) { x = x+ 10; arr[i]= x; } //Accessing the array by foreach loop foreach(int i in arr) { Console.Write(i+" "); } Console.WriteLine(); } }
No comments:
Post a Comment