Click here to Skip to main content
15,913,939 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 all Capital letters Like ANIL.How can i do this please suggest me.


Regards,

Anilkumar.
Posted
Updated 9-Nov-11 1:06am
v2

Try:
C#
FrstName = FrstName.ToUpper();



"So Now i want to Replace Frist Letter with Capital Remainning small means anil should convert Anil.How should Replace?"



It's called Title Case, and the String class does not include it. The TextInfo class does though.
C#
CultureInfo cultureInfo = CultureInfo.CurrentCulture;
TextInfo textInfo = CultureInfo.CurrentCulture.TextInfo;
FrstName = textInfo.ToTitleCase(FrstName);
 
Share this answer
 
v2
Comments
Anil Honey 206 9-Nov-11 7:07am    
Than YOU....
Anil Honey 206 9-Nov-11 22:49pm    
So Now i want to Replace Frist Letter with Capital Remainning small means anil should convert Anil.How should Replace?
OriginalGriff 10-Nov-11 3:42am    
Answer Updated
Add .ToUpper() to your code line

string FrstName=ds.Tables[0].Rows[0][5].ToString().ToUpper();
 
Share this answer
 
Comments
Anil Honey 206 9-Nov-11 22:49pm    
So Now i want to Replace Frist Letter with Capital Remainning small means anil should convert Anil.How should Replace?
add:
C#
using System.Globalization;

and try as :
C#
TextInfo UsaTextInfo = new CultureInfo("en-US", false).TextInfo;

       string capitalized = UsaTextInfo.ToTitleCase(FistName);
 
Share this answer
 
Use this:

to Replace the String with all Capital letters

string FirstName=FrstName.ToUpper();

To convert only first letter to upper

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

string Test=FrstName[0].ToString().ToUpper() + FrstName.Substring(1);
 
Share this answer
 
v2
Comments
sravani.v 10-Nov-11 4:16am    
I think you have alredy posted this question?

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