public string readFile()
{
string text;
using (var streamReader = new StreamReader("c:/aaa/balance.txt",Encoding.UTF8));
{
text = streamReader.ReadToEnd();
}
return text;
}
public double sumOfPlus()
{
double sum = 0;
string text = readFile();
string[] arr = text.Split(',');
for (int i = 0; i < arr.Length; i++)
{
sum += Convert.ToDouble(arr[i]);
}
return sum;
}
}
我不能得到總和的輸出,文件中的數字是有效的。
我得到的轉換線錯誤的說:它不是complibate格式模式從字符串轉換爲雙重不工作在C#
'itws的不complibate pattern'它肯定它不是這個消息.... – Eser
你從該文件中輸入的格式是有缺陷的。 –
我需要做什麼?改變它浮動? –