【发布时间】:2017-01-15 15:54:41
【问题描述】:
我正在使用 MySQL 数据库做一个聊天应用程序,我的目标是在 TXT 中加载我的数据库的所有消息,我正在使用 foreach 循环,但它是逐字加载而不是逐行加载换行:
while (reader.Read())
{
sqlcmd_answ = reader.GetString(0);
foreach (var item in sqlcmd_answ.Split())
{
file.WriteLine(item);
}
}
这是我的数据库: picture of my database
在我的 TXT 中,我明白了:
Hello Stack Overflow Community
我想把所有这些词排成一行…… 谢谢!
【问题讨论】: