简体   繁体   中英

passing string value to double array c#

I currently have a application that reads back the contents of the text file in a string. I want to put all those values in a double array I have created but can't seem to get it to work here is my code :

using (StreamReader sr = new StreamReader("test.txt"))
{
    String line =  sr.ReadToEnd();
    x = doubles;
    Console.WriteLine(x);
}

Everytime I run it I get the error "file could not be read: input string was not in a correct format" Does anyone have any idea whats wrong?

bool bSuccess;
double value;
bSuccess = double.TryParse("3.14", out value);

确保为StreamReader传递文件路径,仅声明没有明显位置的“ test.txt”就不会访问您试图读取的文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM