Convert ArrayList into Array and Array to ArrayList

SheoNarayan
Posted by SheoNarayan under C# category on | Points: 40 | Views : 10729
Below code snippet show how to Convert ArrayList into Array and Array to ArrayList.


// Create the ArrayList first
ArrayList arrayList = new ArrayList();
arrayList.Add("FASDF");
arrayList.Add("dfFASDF");
arrayList.Add("FAdfdSDF");
arrayList.Add("FASDFfdf");

// Convert ArrayList into Array
string[] array = arrayList.ToArray(typeof(string)) as string[];

// Convert Array into ArrayList
ArrayList arrLst = new ArrayList(array);


Thanks

Comments or Responses

Login to post response