hi all,

I am having a string. Now i need to get the last word in that string.

suppose

string text = "Hello.. how are you";

Now i need to get 'you' from that string. can anyone help me..

Thank you.

if it is separated by a space then split the string as

string text = "Hello.. how are you";
String[] splitText=text.Split(' ');
Console.WriteLine(splitText[splitText.Length-1];

this will solve your problem

Hello niths,
Words are separated by spaces. Find where the first space occur. The characters preceding the space will give you the word.
Since you want the last word of the string look for the space from the end.

>>abellazm
You are fast in typing.

This is another solution:

string yourWord = text.SubString(text.LastIndexOf(" "), text.Lenght - text.LastIndexOf(" "));

hey thanks abelLazm... that solved my problem.. :)