Не получается преобразовать ArrayList в double[] - C#
Формулировка задачи:
Не получается преобразовать ArrayList в массив типа double
Console.WriteLine("Чтение файла");
ArrayList file = new ArrayList();
using (StreamReader str = new StreamReader("Open.txt",Encoding.UTF8))
{
string s;
while ((s = str.ReadLine()) != null)
{
file.Add(s);
}
}
Console.WriteLine("Создание массива значений");
double[] znachen = (double[])file.ToArray(typeof(double));Решение задачи: «Не получается преобразовать ArrayList в double[]»
textual
Листинг программы
using System.Collections;
class Program
{
static void Main(string[] args)
{
ArrayList list = new ArrayList {
1.0, 2.0, 3.0
};
double[] array = (double[])list.ToArray(typeof(double));
}
}