c# - How to convert a string to camelcase

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.

<%@ 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;
<html xmlns="http://www.w3.org/1999/xhtml">    
<head id="Head1" runat="server">    
    <title>c# example - string to camelcase</title>    
    <form id="form1" runat="server">    
        <h2 style="color:MidnightBlue; font-style:italic;">    
            c# example - string to camelcase
        <hr width="550" align="left" color="Gainsboro" />    
        <br /><br />  
            Text="string to camelcase"    
More c# examples