List Of Some Instance Method In Array Class

Syntax for CopyTo Method is :-               CopyTo(arrayname,index)
Syntax for GetLength Method is :-          GetLength(dimension)
Syntax for GetLowerBound Method is :- GetLowerBound(dimension)
Syntax for GetUpperBound Method is :- GetUpperBound(dimension)
Syntax for SetValue Method is :-             SetValue(object,index)  
Syntax for GetValue Method is :-            GetValue(index)
-----------------------------------------------------------------------------------------------------
using System;
class InstanceMethodInArrayClass
{
static void Main()
  {
  int[] arr1 = {1,2,3,4,5};

int[,] arr2 = {
{1,2,3},
{4,5,6}
     };

int[] arr3 = new int[5];


Console.WriteLine("--------CopyTo Method-----------------------------");

arr1.CopyTo(arr3,0); //It copy arr1 values to arr3.

foreach(int i in arr3)
{ Console.Write(i + "\t"); }

Console.WriteLine("\n\n--------GetLength Method--------------------------");

int length = arr2.GetLength(1); //It gets the length first dimension of an arr2.

Console.WriteLine("Length of first dimension of an arr2 is :- " + length);

Console.WriteLine("\n--------GetLowerBound Method----------------------");

int lowerbound = arr2.GetLowerBound(1);

Console.WriteLine("Lower Bound of first dimension in an arr2 is :- " + lowerbound);

Console.WriteLine("\n--------GetUpperBound Method----------------------");

int upperbound = arr2.GetUpperBound(1);

Console.WriteLine("Upper Bound of first dimension in an arr2 is :- " + upperbound);
}
}
-----------------------------------------------------------------------------------------------------
NOTE :- 
SetValue And GetValue Method is already used in the Program under
CreateInstance (Static Method In Array Class)
-----------------------------------------------------------------------------------------------------

List Of Some Instance Method In Array Class List Of Some Instance Method In Array Class Reviewed by Baljeet Singh on 08:28 Rating: 5

No comments:

Powered by Blogger.