0

Hi there, i would like to know how to get the first letter of all the word in a string.

If i have a string

mystring="Name Surname"

i would like to get only the fist letter of each words and the results will be

N S

Anybody could help with that?

thanks

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by Freshbee
0
mystring=Split("Name Surname")
for each x in mystring


    response.write(left(x,1) & "<br />")


next

Edited by hingoro

0

//Dude I have written the following code in console application.It worked correctly.I am assuming you know how to //take user input and store it in the string variable.Also, that you now how to write to output.you need to focus at //the for loop.

        string mystring = "";
        Console.WriteLine("Please enter a name");
        name = Console.ReadLine();

        for (int i = 0; i < name.Length; i++)
        {
            //bool b = false;
            if (i == 0)
            {
                Console.Write("{0} ",name[i]);
            }
            while(name[i] ==' '  )
            {
                i++;
                if (name[i] != ' ')
                {
                    Console.Write("{0} ", name[i]);
                }
            }
        }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.