Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
C# Array Programs
C# Array Programs
An array is a variable that stores a collection of values of the same type. Array variables are sorted and each variable has an index starting at 0. Memory allocation for arrays in C# is done dynamically. Since arrays are objects, their size can be easily determined using built-in functions. The maximum number of elements that an array may hold is referred to as its length or size. C# array variables can be declared exactly like any other variable by adding [] after the data type.
C# Array Types:
In C# programming, there are three types of arrays:
- Single Dimensional Array
- Multidimensional Array
- Jagged Array
Single Dimensional Array
A single-dimensional array is the simplest type of array in C# that contains only one row to store the values of the same data type. It is also known as a one-dimensional array.
Multidimensional Array
A multidimensional array in C# is an array containing many rows to store data. It is also known as a two-dimensional array.
Jagged Array
A Jagged Array is an array whose elements are arrays. The elements of the jagged array vary in size and dimension.
Advantages of C# Arrays:
- It’s used to give a single name to a collection of data items that are all of the same kind.
- Since C# arrays are strongly typed, the efficiency of the program is improved because there is no boxing and unboxing.
- Easy to traverse, manipulate or sort the data.
- Other data structures, such as linked lists, graphs, trees, stacks, and queues, can be implemented using arrays.
Disadvantages of C# Arrays:
- Fixed array size.
- An element can never be inserted or deleted in the middle of an array.