首先让我提出代码:
private void AdicionarFormula(string x, string y, string Materia)
{
MessageBox.Show("%" + x + " = " + y + "#" + Materia);
StreamWriter Escritor = new StreamWriter(Properties.Settings.Default.ArquivoDeFormulas, true);
Escritor.WriteLine("%" + x + " = " + y + "#" + Materia);
Escritor.Close();
LerFormulas(true);
}
问题是:而不是输出为"%x = y#Materia
“它实际上是”
%x = y
#Materia"
我不希望它为“#Materia”创建一个新行。
答案 0 :(得分:1)
您的参数' y'包含char换行符。例如,在您的代码中尝试:
string.Format("%" + x + " = " + y + "#" + Materia).Replace("\n","")