ToCamelCase

  public static string ToCamelCase(this string the_string)
        {
            if (the_string == null || the_string.Length < 2)
                return the_string;

            string[] words = the_string.Split(
                new char[] { },
                StringSplitOptions.RemoveEmptyEntries);

            string result = words[0].ToLower();
            for (int i = 1; i < words.Length; i++)
            {
                result +=
                    words[i].Substring(0, 1).ToUpper() +
                    words[i].Substring(1);
            }

            return result;
        }
Example:
Var str="this is Sampel String".ToCamelCase();

Description

Convert a String into CamelCase

Details

  • Author: Anonymous
  • Submitted on: 4/27/2016 2:00:07 PM
  • Language: C#
  • Type: String
  • Views: 932

Double click on the code to select all.

 

;