ArrayList কে Array-তে রূপান্তর করতে C#-এ ToArray() মেথড ব্যবহার করুন।
প্রথমে একটি ArrayList সেট করুন:
ArrayList arrList = new ArrayList();
arrList.Add("one");
arrList.Add("two");
arrList.Add("three");
এখন রূপান্তর করতে ToArray() মেথড ব্যবহার করুন:
arrList.ToArray(typeof(string)) as string[];
সম্পূর্ণ উদাহরণ
using System;
using System.Collections;
public class Program
{
public static void Main()
{
ArrayList arrList = new ArrayList();
arrList.Add("one");
arrList.Add("two");
arrList.Add("three");
string[] arr = arrList.ToArray(typeof(string)) as string[];
foreach (string res in arr)
{
Console.WriteLine(res);
}
}
}
আউটপুট
one two three