Hey guys, I want to ask whether in C# I can take a values from a textbox words like in C++ console.readline..

Example :
user : What is Apple
application will take the last word of it which is apple. and will reply
apps: Apple is a fruit

is it possible?

Thanks in advance.. i need to know how to take that last words..

Don't really get it.
Do you want to use a textbox as some sort of console?
If you want to extract some strings from a string object, you could use the methods Split or SubString.

public String GetLastWord(String input) {
    String[] parts = input.Split(new char[] {' ', '.', '?', '!'}, StringSplitOptions.RemoveEmptyEntries);
    return parts[parts.length-1];
}

try this piece of code:

static void Main(string[] args)
        {
            string str1 = "Users: What is Apple?";
            string[] arrayS = str1.Split(' ');
            string str2 = arrayS[arrayS.Length - 1];
            if (str2.Contains("?") || str2.Contains("!") || str2.Contains(".") || str2.Contains(","))
                str2 = str2.Remove(str2.Length - 1, 1);
            Console.WriteLine("{0} is a frut.", str2);
            Console.ReadLine();
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.