代码在运行多次后切断字符串

发布于 2024-10-06 08:40:58 字数 611 浏览 0 评论 0原文

这段代码在循环中运行。在第 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回首观望 2024-10-13 08:40:58

确保您已刷新 outfile 缓冲区。

Make sure you have flushed your outfile buffer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文