how can we know how many words in txt file depending on white space ? C# console

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi,
i have a txt file contains
"hi this is
a text file
t h a n k s"
how can i know how many word depend on white space .. i dont need to use split .. just white space
i knew how can i count line by this
<pre class="prettyprint StreamReader reader = new StreamReader("../../../data1.txt");
FileInfo filelength = new FileInfo("../../../data1.txt");
long length = filelength.Length;

string character; int line=1;

for (int i = 0; i < length; i++)
{
character = reader.Read().ToString("X2");
Console.Write(" " + character);
// to check how many lines in file depending on t
if (character == "0D")
{
line++;
}
}[/code]
<br/>
but words .. i couldnt ..
could u help me plz
<br/>

View the full article
 
Back
Top