Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#在文本文件中分隔单词_C#_Text Files - Fatal编程技术网

C#在文本文件中分隔单词

C#在文本文件中分隔单词,c#,text-files,C#,Text Files,我有一个文本文件,其中有许多单词被隔开。看起来是这样的: eye;hand;mouth;arms;book three;head;legs;home string g = readText.Replace(";", "\n"); 我想浏览这个文件并搜索符号并修改文件,使每个单词都换位换行符 string g = readText.Replace(";", "\n"); 我应该先用 string path = @"c:\temp\MyTest.txt"; string readText =

我有一个文本文件,其中有许多单词被
隔开。看起来是这样的:

eye;hand;mouth;arms;book
three;head;legs;home
string g = readText.Replace(";", "\n");
我想浏览这个文件并搜索符号
并修改文件,使每个单词都换位换行符

string g = readText.Replace(";", "\n");
我应该先用

string path = @"c:\temp\MyTest.txt";
string readText = File.ReadAllText(path);
string g = readText.Replace(";", "\n");
然后检查:

if readText.contains(";");
string g = readText.Replace(";", "\n");

但是我不知道下一步该怎么办你是说这个吗

string g = readText.Replace(";", "\n");
使用

string g = readText.Replace(";", "\n");
使用readText,替换(“;”,Environment.NewLine)