Category: Education

Presentation Description

array in c sharp... hv not attached programs for practical implementation. if u want programs do inform me i ll send them..


Presentation Transcript




CONTENTS What is array? Array Properties. Types of Arrays One Dimensional Array Two Dimensional Array Jagged Array Mixed Arrays


CONTINUED Array Class ArrayList Class

What is an ‘ARRAY’?:

What is an ‘ARRAY’?

Array Properties:

Array Properties IsFixedSize Return a value indicating if an array has a fixed size or not. IsReadOnly Returns a value indicating if an array is read-only or not. LongLength Returns a 64-bit integer that represents total number of items in all the dimensions of an array. Length Returns a 32-bit integer that represents the total number of items in all the dimensions of an array. Rank Returns the number of dimensions of an array.

Defining arrays of different types:

Defining arrays of different types double[] doubleArray = new double[5]; char[] charArray = new char[5]; bool[] boolArray = new bool[2]; string[] stringArray = new string[10];

Array Types:

Array Types Single-dimensional arrays Multidimensional arrays or rectangular arrays Jagged arrays Mixed arrays.

Single Dimension Arrays:

Single Dimension Arrays int [] arr ; arr = new int [3];


Initialization // Initialize a fixed array int [] IntArray = new int [3] {1, 3, 5}; // Initialize a fixed array one item at a time int [] IntArray = new int [3]; IntArray [0 ] = 1; IntArray [1 ] = 3; IntArray [2 ] = 5;


Continued…. // Initialize a dynamic array items during declaration string[] strArray = new string[] { "Mahesh Chand", "Mike Gold", "Raj Beniwal ", "Praveen Kumar", "Dinesh Beniwal " };

Practical Implementation:

Practical Implementation

MultiDimension Arrays:

MultiDimension Arrays int [,] numbers = new int [3, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 } }; string[,] names = new string[2, 2] { { "Rosy", "Amy" }, { "Peter", "Albert" } };

Practical Implementation:

Practical Implementation

Jagged Arrays:

Jagged Arrays int [][] intJaggedArray = new int [3 ][]; intJaggedArray [0] = new int [2]; intJaggedArray [1] = new int [4]; intJaggedArray [2] = new int [6];

Practical Implementation:

Practical Implementation

Mixed Arrays:

Mixed Arrays Combination of 1-D, multidimensional and jagged array

Practical Implementation:

Practical Implementation

Array Class:

Array Class Array class is the mother of all arrays and provides functionality for creating, manipulating, searching, and sorting arrays in .NET Framework.

Method/Property in Array Class:

Method/Property in Array Class Method/Property Purpose Clear() Sets a range of elements to empty values CopyTo () Copies elements from source to destination array GetLength () Gives the number of elements in a given dimension of the array GetValue () Gets the value for a given index in the array Length() Gives the length of array SetValue () Sets the value for given index in an array Reverse() Reverse the contents of 1-D array Sort() Sort the elements in –D array

Array ListClass:

Array ListClass Implements the IList interface using an array whose size is dynamically increased as required.

ArrayList Class Properties:

ArrayList Class Properties Method/Property Purpose Add() Adds an object to a list Clear() Removes all the elements from the list Insert() Inserts an element into the list Contains() Determines if an element in the list()

ArrayList Class Properties:

ArrayList Class Properties Name Description Capacity Gets or sets the number of elements that the ArrayList can contain. count Gets the number of elements actually contained in the ArrayList . isFixedOnly Gets a value indicating whether the ArrayList has a fixed size. IsReadOnly Gets a value indicating whether the ArrayList is read-only. Item Gets or sets the element at the specified index


References Programming in C# by E Balagurusamy aspx

PowerPoint Presentation:

Thank you

Presented by:-:

Presented by:- Amitjot Kaur Nantawo Caroline

authorStream Live Help