c# StreamWriter 应用中,我想每一行中写入两个不同性质的数据,该怎么写呢
StreamWritersw=newStreamWriter("D:\\TEST\\testWinform_v1.8(1)\\IDandsimilarity.txt");...
StreamWriter sw = new StreamWriter("D:\\TEST\\testWinform_v1.8(1)\\ID and similarity.txt");
for (int i = 0; i < count1; i++)
{
sw.WriteLine(similar.ShapeRecords[i].ProductID);
sw.WriteLine(similar.ShapeRecords[i].Similarity);
}
我不想让ProductID和Similarity这两个数据分成两行,想在一行显示出来,该怎么做 展开
for (int i = 0; i < count1; i++)
{
sw.WriteLine(similar.ShapeRecords[i].ProductID);
sw.WriteLine(similar.ShapeRecords[i].Similarity);
}
我不想让ProductID和Similarity这两个数据分成两行,想在一行显示出来,该怎么做 展开
3个回答
展开全部
第一行写入ProductID时不写入换行就行了。
StreamWriter sw = new StreamWriter("D:\\TEST\\testWinform_v1.8(1)\\ID and similarity.txt");
for (int i = 0; i < count1; i++)
{
sw.Write(similar.ShapeRecords[i].ProductID);
sw.WriteLine(similar.ShapeRecords[i].Similarity);
}
StreamWriter sw = new StreamWriter("D:\\TEST\\testWinform_v1.8(1)\\ID and similarity.txt");
for (int i = 0; i < count1; i++)
{
sw.Write(similar.ShapeRecords[i].ProductID);
sw.WriteLine(similar.ShapeRecords[i].Similarity);
}
展开全部
把第一个WriteLine改成Write
WriteLine的意思就是写完一段话换行
WriteLine的意思就是写完一段话换行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
StreamWriter sw = new StreamWriter("D:\\TEST\\testWinform_v1.8(1)\\ID and similarity.txt");
for (int i = 0; i < count1; i++)
{
sw.WriteLine(similar.ShapeRecords[i].ProductID+" "+similar.ShapeRecords[i].Similarity);
// sw.WriteLine(similar.ShapeRecords[i].Similarity);
}
for (int i = 0; i < count1; i++)
{
sw.WriteLine(similar.ShapeRecords[i].ProductID+" "+similar.ShapeRecords[i].Similarity);
// sw.WriteLine(similar.ShapeRecords[i].Similarity);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询