Thank you both of you. Tihs line thingy has already been done. Let me brief you what I want to do, please have a look to the following code
string[] tempArray = new string [rch.Lines.Length];
tempArray = rch.Lines;
MessageBox.Show ("Characters are "+rch.TextLength.ToString ()); //number of char
MessageBox.Show ("Lines are " +rch.Lines.Length.ToString ()); //how manylines,
string gg;
int count=0;
string[] kk= new string[rch.Lines.Length];
for(int b = 0;b<tempArray[0].Length ;b++)
{
gg=tempArray[0].Substring(b,1);
kk[count]=kk[count]+ tempArray[0].Substring (b,1);
switch (gg)
{
case ("\n"):
count ++;
break;
case (" "):
count ++;
break;
case (" "): //detecting for tow white spaces
count ++;
break;
}
} // end for
MessageBox.Show("there are " + count.ToString ()+ " words in line 1");
MessageBox.Show ("There are "+tempArray[0].Length.ToString ()+" characters in first line" );
What this code is doing is, while consider the for loop only, to count number of words in an array containing the first line of richtext box. But this switch case doenst work for "\n" i.e. new line and if a line has more than one white spaces then it wont work. I think the reason is this
gg=tempArray[0].Substring(b,1);
It is detecting the line 1 , char by char...............
How can I fix my code for if a user enters more than one whitespaces and to detect the "\n" thingy.
Warm Regards,