这些是values
从textfile
1245.67
1189.55
1098.72
1456.88
2109.34
1987.55
1872.36
他们显然decimal
是
不知道我错过了什么,但是当我调试时,我得到输入字符串的格式不正确,任何帮助都会很棒
这就是我到目前为止编码的内容
private void getValuesButton_Click(object sender, EventArgs e)
{
try
{
//create an array to hold items read from the file.
const int SIZE = 7;
double[] numbers = (double[])ois.readObject();
// Counter variable to use in the loop
int index = 0;
//Declare a StreamReader variable
System.IO.StreamReader inputFile;
//Open the file and get a StreamReader object.
inputFile = File.OpenText("Values.txt");
//Read the file contents into the array.
while (index < numbers.Length && !inputFile.EndOfStream)
{
numbers[index] = int.Parse(inputFile.ReadLine());
index++;
}
//Close the file.
inputFile.Close();
//Display the array elements in the list box.
foreach (double value in numbers)
{
outputListbox.Items.Add(value);
}
}
catch (Exception ex)
{
//Display an error message.
MessageBox.Show(ex.Message);
}