c# - Issue with adding a Double to a List<double> -


i'm getting issue adding double list<double> csv file. i've done before, exact same file, , added double array. here code works array:

double[] ch1array = new double[arraysize];  if (openfiledialog1.showdialog() == dialogresult.ok) {                   string filename = path.combine(filepath, openfiledialog1.filename);                    var reader = new streamreader(file.openread(filename));     while(!reader.endofstream)    {       var line = reader.readline(); //get through column titles       var values = line.split(',');       if (datasize > 0)       {          try          {              ch1array[datasize] = convert.todouble(values[1]);              //etc... 

this code works , thing change not using array anymore , instead using list<double>:

            list<double> ch1array = new list<double>();              if (openfiledialog1.showdialog() == dialogresult.ok)             {                 //create stream reader , open file                 string filename = path.combine(mainfilepath, openfiledialog1.filename);                 var reader = new streamreader(file.openread(filename));                  int counter = 0;                  //read document until end of stream                 while (!reader.endofstream)                 {                     var line = reader.readline();                      var values = line.split(',');                      try                     {                            ch1array.add(convert.todouble(values[1]));                         //etc.. 

now assuming using list wrong (it's first time have used lists). once program gets section (it compiles , runs fine) tells me have error , input string not in correct format. since can use variable values[1] in other contexts double don't know doing throwing error. can tell me doing wrong?

edit: here exception thrown: enter image description here

you said message box showing value "3276". means you're trying convert.todouble("\"3276\"") throw exception you're getting.

change following line:

convert.todouble(values[1]) 

to:

convert.todouble(values[1].replace("\"","")); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -