G
Guest
I would simply like to convert the arraylist i read in to an array of type
double. The code below gives me an error that at least one element in the
source array could not be cast down to the destination array. What do I need
to change?
using System;
using System.IO;
using System.Collections;
namespace Program2
{
class Class1
{
static public void Main(string[] args)
{
{
StreamWriter swa=new StreamWriter("c:\\afinal.txt");
StreamReader sra=new StreamReader("c:\\Acolumn.txt");
string aLine="";
ArrayList aColumn = new ArrayList ();
while (aLine != null)
{
aLine=sra.ReadLine();
if (aLine != null)
aColumn.Add(aLine);
Console.WriteLine(aLine);
}
Console.ReadLine();
sra.Close();
double[] AField = (double[])aColumn.ToArray (typeof (double));
Console.WriteLine (AField);
}
Console.ReadLine();
}}}
double. The code below gives me an error that at least one element in the
source array could not be cast down to the destination array. What do I need
to change?
using System;
using System.IO;
using System.Collections;
namespace Program2
{
class Class1
{
static public void Main(string[] args)
{
{
StreamWriter swa=new StreamWriter("c:\\afinal.txt");
StreamReader sra=new StreamReader("c:\\Acolumn.txt");
string aLine="";
ArrayList aColumn = new ArrayList ();
while (aLine != null)
{
aLine=sra.ReadLine();
if (aLine != null)
aColumn.Add(aLine);
Console.WriteLine(aLine);
}
Console.ReadLine();
sra.Close();
double[] AField = (double[])aColumn.ToArray (typeof (double));
Console.WriteLine (AField);
}
Console.ReadLine();
}}}