In C#, a multidimensional array is an array that contains more than one dimension, such as a two-dimensional array or a three-dimensional array. A two-dimensional array is an array of arrays, where each inner array represents a...
Tag - C# Array Examples
Use For Loop With Array in C#
For-loop. With this loop we use indexes. We have a start, and end, and increment expression. We must then access the element from the array in an expression within the loop. Here: We use a for-loop to iterate over a string array...
Use Foreach With Array in C#
In C#, the foreach loop iterates collection types such as Array, ArrayList, List, Hashtable, Dictionary, etc. It can be used with any type that implements the IEnumerable interface. C# Code: C# static void Main(string[] args) {...
C# Program that gets last array element
In this example i’ll show you, How to get the last element from an array using C#. C# Code: C# static void Main(string[] args) { string[] arr = { "C#", "Python", "C++", "Java" }; // Get the last string element. string last...
C# Find odd Number in Array
In this tutorial I will show how to find Odd numbers in C#. I have given two example first example is very simple. First example I have used simple for loop to find Odd numbers.Second example I have created a Linq for finding Odd...
C# Program for Left and Right Rotation of an Array
Array Rotation simply means shifting the array elements to the left or right of the array by specified positions. An array can be rotated to the left(clockwise) or to the right (anti-clockwise) to the given number of positions...
How to Convert a String Array to an int Array in C#
Convert a String Array to an int Array. C# Code: C# using System; using System.Linq; class Program { static void Main(string[] args) { //this line create a string variable. string[] stringOfInteger = { "1", "5", "10", "15", null...
Access Array Elements Using Different Loops in C#
In this tutorial, we’ ll learn How to access array elements using loops (for, while, foreach, do-while) in C#. C# Code: C# class GFG { // Main Method public static void Main() { // declares an Array of integers. int[]...
Sort an Array in Descending Order Without Using inbuilt C# Function.
In this example, we’ll learn How to Sort an array in descending order without using inbuilt C# function. C# Code: C# static void Main(string[] args) { int[] intArray = new int[] {2,9,4,3,5,1,7 }; int temp = 0; for (int i =...
Sort an Array in Ascending Order Without Using inbuilt C# Function
In this example, we’ ll learn How to Sort an array in ascending order without using inbuilt C# function. C# Code: C# static void Main(string[] args) { int[] intArray = new int[] {2,9,4,3,5,1,7 }; int temp = 0; for (int i =...