Camel case is the practice of writing phrases without spaces or punctuation. It indicates the separation of words with a single capitalized letter, and the first word starting with either case. Common examples include "iPhone" and "eBay".
Change to CamelCase
public static string ToCamelCase(this string text)
{
TextInfo _textInfo = CultureInfo.InvariantCulture.TextInfo;
char[] _camelCase = _textInfo.ToTitleCase(text).Replace(" ","").ToCharArray();
_camelCase[0] = char.ToLower(_camelCase[0]);
return new string(_camelCase);
}
Explanation
To reach camelCase, we do the following
- First make it TitleCase
- Remove the " " (spaces)
- Lowercase the first character
NuGet Package
You can create the extension yourself, or you can download the latest version of CodeHelper.Core.Extensions
This packages contains much more cool and fun string extensions
Top comments (0)