Reading the contents of a txt/CSV file into an array
-
Hello list, I've found myself in a bit of a pickle in trying to do something that is intuitively simple. I'm relatively new to coding, esp. in C#, so I hope you don't mind a novice-level question. Here's what I need to do: 1. I have a text file with some data, and each line in the text file is a number of type "double". 2. I would like the user to be able to click a button on the application's form, navigate to this text file and be able to read ALL available lines (numbers) into an array of doubles. I've figured out how to put the button on the form and the use of the OpenFileDialog. I just don't seem to be doing the reading of data into the array correctly. Your help would be greatly appreciated! Thank you.
-
Hello list, I've found myself in a bit of a pickle in trying to do something that is intuitively simple. I'm relatively new to coding, esp. in C#, so I hope you don't mind a novice-level question. Here's what I need to do: 1. I have a text file with some data, and each line in the text file is a number of type "double". 2. I would like the user to be able to click a button on the application's form, navigate to this text file and be able to read ALL available lines (numbers) into an array of doubles. I've figured out how to put the button on the form and the use of the OpenFileDialog. I just don't seem to be doing the reading of data into the array correctly. Your help would be greatly appreciated! Thank you.
You might want to check out the
StreamReader
class. It has aReadLine
method which should be able to help you. TheConvert
class would be able to help you do the conversion from string to double. Weiye Chen Life is hard, yet we are made of flesh... -
You might want to check out the
StreamReader
class. It has aReadLine
method which should be able to help you. TheConvert
class would be able to help you do the conversion from string to double. Weiye Chen Life is hard, yet we are made of flesh...