String to camelcase
The following asp.net c# example code demonstrate us how can we convert a string to title case/camel case
characters programmatically at run time in an asp.net application. .Net framework's String Class represent text as
a series of Unicode Characters.
.Net framework's TextInfo.ToTitleCase() method allow us to convert the specified string to title case but the words that are entirely in uppercase, which are considered to be acronyms. The ToTitleCase() method require to pass a parameter named 'str' which represent the string to convert to title case (camel case).
TextInfo.ToTitleCase() method return value data type is System.String which is the specified string converted to title case. ToTitleCase() method throw ArgumentNullException exception, if the parameter value is null. Generally, title casing converts the first character of a word to uppercase and the rest of the character to lowercase.
.Net framework's TextInfo.ToTitleCase() method allow us to convert the specified string to title case but the words that are entirely in uppercase, which are considered to be acronyms. The ToTitleCase() method require to pass a parameter named 'str' which represent the string to convert to title case (camel case).
TextInfo.ToTitleCase() method return value data type is System.String which is the specified string converted to title case. ToTitleCase() method throw ArgumentNullException exception, if the parameter value is null. Generally, title casing converts the first character of a word to uppercase and the rest of the character to lowercase.
string-to-camelcase.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<%@ Import Namespace="System.Globalization" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
//this section create string variables.
string birds = "grey gull. laughing gull. spotted sandpiper.";
Label1.Text = "string of birds..................<br />";
Label1.Text += birds;
//this line create a new TextInfo based on en-US culture
TextInfo tInfo = new CultureInfo("en-US", false).TextInfo;
//this line applying title case to string.
birds = tInfo.ToTitleCase(birds);
Label1.Text += "<br /><br />string of birds with camelcase..................<br />";
Label1.Text += birds;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to camelcase</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to camelcase
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="string to camelcase"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>

- How to append a substring to a string
- How to append a char to a string
- How to find a substring within a string
- How to find index of a substring in a string
- How to create a string by repeating a character
- How to get number of characters from right side of a string
- How to format a string as currency
- How to get color from string
- How to convert a hex string to color
- How to split a string to key value pairs