Conversion Of Array Class to Simple Array and Vice -Versa
using System;
class ConversionOfArrays
{
public static void Main()
{
Array arr1 = Array.CreateInstance(typeof(int),2); //Create Obejct of Array Class
arr1.SetValue(10,0);
arr1.SetValue(20,1);
foreach(int i in arr1)
Console.Write(i + " " );
Console.WriteLine();
int[] iarr1= new int[2]; //Assign Array Class to Standard Array
iarr1 = (int[])arr1; //Type casting from Array Class to Simple Array
foreach(int i in iarr1)
Console.Write(i + " " );
Console.WriteLine();
Array arr2 = Array.CreateInstance(typeof(int),2);
arr2 = iarr1; //Assign Standard Array to Array Class
foreach(int i in arr1)
Console.Write(i + " " );
Console.WriteLine();
}
}
-------------------------------------------------------------------------------------------------------
Conversion Of Array Class to Simple Array and Vice -Versa
Reviewed by Baljeet Singh
on
05:26
Rating:
No comments: