Created
October 27, 2020 10:53
-
-
Save ArtemAvramenko/5472b2c4dcc9d431695bad98f44fdc41 to your computer and use it in GitHub Desktop.
C# camel case coverter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string ToCamelCase(string text) | |
{ | |
if (text != null) | |
{ | |
var upperCount = 0; | |
while (upperCount < text.Length && char.IsUpper(text, upperCount)) | |
{ | |
upperCount++; | |
} | |
if (upperCount > 1 && upperCount < text.Length && char.IsLower(text, upperCount)) | |
{ | |
upperCount--; | |
} | |
if (upperCount > 0) | |
{ | |
text = text.Substring(0, upperCount).ToLowerInvariant() + text.Substring(upperCount); | |
} | |
} | |
return text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment