我有一个10×10的文本框(其中100) 我写这篇文章的代码写入到文本文件:写入文本文件不匹配
foreach (Control control in Panel1.Controls)
{
var textBox = control as TextBox;
if (textBox != null)
{
if (string.IsNullOrEmpty(textBox.Text)) // ignore this
{
textBox.Style["visibility"] = "hidden";
}
textBox.Enabled = false;
if (numberofCommas > 8)
{
stringWriter.Write(textBox.Text);
numberofCommas = 0;
}
else
{
stringWriter.Write("," + textBox.Text);
numberofCommas++;
recordsWritten++;
}
if (recordsWritten == 10)
{
stringWriter.WriteLine();
recordsWritten = 0;
}
else
{
}
从上面我想有10行在文本文件中有9个逗号,但是我在文本文件中有9行10个逗号,是我的代码逻辑错误?因为我一直在看它几个小时,我仍然无法解决它。对不起,如果我的逻辑不好,我是编程新手。