Вы находитесь на странице: 1из 2

C# Programming Examples on Arrays

This section covers C# programming examples on Arrays. Every example


program includes the description of the program, C# code as well as output
of the program. All examples are compiled and tested on a Visual Studio.
These examples can be simple C# programs or advanced C# programs. So,
they are suitable for any user (dummies, beginners or advanced users).

Here is the listing of C# programming examples on Arrays.


1. C# Examples on different types of Arrays

An array is a variable that holds fixed number of values of a certain type. The
no of elements an array can hold is called the length or the size of an array. It
is used for looping and accessing over the last element. One dimensional
array is the simplest type of array in C# that contains only one row to store
value in same data type. A two-dimensional array contains two indices to
select an element. An array whose elements are again arrays is called a
Jagged Array. The elements of a jagged array are of different dimensions and
sizes. The number of dimensions of an array is called its rank. Each
dimension in an array has an upper and lower bound, which gives the range
of values that can be used as subscripts for that dimension. The programs in
this section perform conversion of a 2D array into 1D array, finds the length
array length, determines the upper bound and lower bound of an array,
evaluates the rank of a given array and demonstrates the functionalities of a
jagged array.
C# Program to Convert a 2D Array into 1D Array
C# Program to get the Length of the Array
C# Program to Get Lower Bound and Upper Bound of an Array
C# Program to Find the Rank of a given Array
C# Program to Demonstrate Jagged Arrays
2. C# Examples on Indexing

Indexers treat the objects same like arrays. Array indexing uses of square
brackets ([]) to index array values. The programs in the following section
takes two input arrays and produces a third array by joining one array to

another. The remaining programs in the section searches for an array


element using array indices, demonstrates the usage of array indexers and
finds the maximum and minimum numbers(largest and smallest) in the given
array.
C# Program to Get 2 Arrays as Input and Produce a 3rd Array by Appending
one to other
C# Program to Search an element with Array Indices
C# Program to Implement Use of Indexers
C# Program to Find Minimum and Maximum of Numbers
3. C# Examples on Sorting, Searching, Copy and Reverse Operations

The programs in this section perform sorting, searching, copy and reverse
operations on the elements of an array. The programs sorts a list of names
alphabetically, copies a section of one array into another, searches for a
given element in an array and reverses the contents of an array.
C# Program to Copy a Section of One Array to Another
C# Program to Sort a List of Names in Alphabetical Order
C# Program to Search an Element in an Array
C# Program to Reverse an Array
4. C# Examples on Negation and Average Operations

The negation operator (!) negates or flips the meaning of its operand. The
program in the section negates the positive elements of an array. The
average of the set of values is the sum of the values divided by the total
number of the values. The following program finds the average of all the
elements in the array and the remaining program in the section finds the
length of the jagged array using certain pre-defined functions.
C# Program to Negate the Positive Elements of Array
C# Program to Find the Average Values of all the Array Elements
C# Program to Find the Length of the Jagged Array using Predefined
Functions

Вам также может понравиться