Convert string to Proper case in Dot Net

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 1190
Here is the code to convert string to Proper case for ex. mcdonald --> McDonald, neil o'brien --> Neil O'Brien
public string ToProperCase(string Input)
{
if (string.IsNullOrWhiteSpace(Input))
return string.Empty;
else
{
System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Globalization.TextInfo Text_Info = cultureInfo.TextInfo;
return Text_Info.ToTitleCase(Input.ToLower());
}
}

Response.Write(ToProperCase("vishal.neeraj" + "<br/>")); //Vishal.Neeraj
Response.Write(ToProperCase("dotnet funda" + "<br/>")); //Dotnet Funda

Comments or Responses

Login to post response