Click here to Skip to main content
15,896,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

Iam getting some name from database like this


string FrstName=ds.Tables[0].Rows[0][5].ToString(); 

so,in Frstname the string is like this anil.Now i want to replace anil with Frist letter Should be Capital and Remainning letters with Small letters Like Anil.How can i do this please suggest me.


Regards,

Anilkumar.D
Posted
Updated 9-Nov-11 18:27pm
v2

Use System.String methods: Substring(Int32), ToUpper, ToLower, Format, last method to combine first letter with the rest of string obtained via fist method; see http://msdn.microsoft.com/en-us/library/system.string.aspx[^].

—SA
 
Share this answer
 
 
Share this answer
 
Hi,

Try Following....

string FrstName=ds.Tables[0].Rows[0][5].ToString(); 

string Test=FirstName[0].ToString().ToUpper() + FirstName.Substring(1);


Hope this helps....
 
Share this answer
 
v2
Comments
Anil Honey 206 10-Nov-11 1:09am    
I got It Thanx a Lot..........
try the following

string myString = TextBox1.Text.ToString();
string touppercasestring=char.ToUpper(myString [0]) + myString.Substring(1)
return touppercasestring


hope this helps
 
Share this answer
 
Comments
Anil Honey 206 10-Nov-11 1:09am    
I got It Thanx a Lot..........

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