代码在运行多次后切断字符串
这段代码在循环中运行。在第 38 次运行后,打印到文本文件的字符串在第二个“M”之后立即被切断,甚至不打印逗号,然后停止打印所有内容并结束。
这可能是什么原因造成的?
private static void LogPayment(CDefeasancePayment paymentToLog, System.IO.StreamWriter outfile)
{
string line = "AddDefeasancePayment(DateTime.Parse(\"" + paymentToLog.PaymentDate.ToShortDateString() +
"\"), " + paymentToLog.Interest +
"M, " + paymentToLog.Principal + "M, DateTime.Parse(\"" +
paymentToLog.StripDate.ToShortDateString() + "\"), " + paymentToLog.StripPrice +
"M);\n";
outfile.Write(line);
}
This code runs in a loop. After the 38th time it runs, the string that gets printed to the text file cuts off immediately after the second "M", doesn't even print the comma, and then stops printing everything and ends.
What could be the cause of this?
private static void LogPayment(CDefeasancePayment paymentToLog, System.IO.StreamWriter outfile)
{
string line = "AddDefeasancePayment(DateTime.Parse(\"" + paymentToLog.PaymentDate.ToShortDateString() +
"\"), " + paymentToLog.Interest +
"M, " + paymentToLog.Principal + "M, DateTime.Parse(\"" +
paymentToLog.StripDate.ToShortDateString() + "\"), " + paymentToLog.StripPrice +
"M);\n";
outfile.Write(line);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您已刷新
outfile
缓冲区。Make sure you have flushed your
outfile
buffer.