Click here to Skip to main content
15,885,758 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to change the first letters of full name inserted into the textbox;

for if user inputs: "subash neupane" after conversion it should be "Subash Neupane"

for this.

I had used the uppercase conversion string function

public string change(string str1)
       {
           return char.ToUpper(str1[0]) + str1.Substring(1);
       }



can give some hints how to change for the lastname too?
Posted
Updated 3-Jul-11 22:01pm
v2
Comments
Sergey Alexandrovich Kryukov 4-Jul-11 3:56am    
Are you serious? You're almost there, one more brain effort and you're done!
--SA

Have you checked this?

http://msdn.microsoft.com/en-us/library/system.globalization.textinfo.totitlecase.aspx[^]

You can use ToTitleCase() method like following

string titleCaseString = new System.Globalization.CultureInfo("en").TextInfo.ToTitleCase("subash neupane");
 
Share this answer
 
v5
Comments
Sergey Alexandrovich Kryukov 4-Jul-11 4:04am    
A 5, but you removed OP's chance to think just a bit more. :-)
--SA
sanomama 4-Jul-11 4:20am    
i had no idea about culture info!!
thanks all.
Sergey Alexandrovich Kryukov 5-Jul-11 0:51am    
Yes, the importance of it is this: ToLower or ToUpper case operations are not culture-neutral, as in some languages/cultures there are more complex rules of capitalization -- hence the CultureInfo. For the culture "en" it makes no sense, but this is just for example, there should not be an immediate string constant here.

Wait a minute... I think "new" is lost, must be "new CultureInfo("en").
Prakash, please fix it.
--SA
PSK_ 5-Jul-11 4:17am    
Good catch :) Fixed now. Thanks
Sergey Alexandrovich Kryukov 5-Jul-11 4:41am    
You're welcome. I already voted 5. Wow, you have 5*5 votes! Well earned though; using culture info is important point here.
--SA
store full name in any string.

then transfer it to string array using space as string seperator

then do for each string what u have done for first

finally cocatenate it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900