我有一个文本文件,其中有许多单词以;
分隔。它看起来像这样:
eye;hand;mouth;arms;book
three;head;legs;home
我想浏览此文件并搜索符号;
并修改文件,以便每个字都换行换行。
我是否应首先使用
读取字符串中的文本文件string path = @"c:\temp\MyTest.txt";
string readText = File.ReadAllText(path);
然后检查:
if readText.contains(";");
但我不知道接下来该做什么
答案 0 :(得分:5)
string readText = File.ReadAllText(path);
var result = readText.Replace(";", Environment.NewLine);
答案 1 :(得分:2)
使用
readText.Replace(";",Environment.NewLine)
答案 2 :(得分:1)
string g = readText.Replace(";", "\n");