Skip to content

Instantly share code, notes, and snippets.

@ArtemAvramenko
Created October 27, 2020 10:53
Show Gist options
  • Save ArtemAvramenko/5472b2c4dcc9d431695bad98f44fdc41 to your computer and use it in GitHub Desktop.
Save ArtemAvramenko/5472b2c4dcc9d431695bad98f44fdc41 to your computer and use it in GitHub Desktop.
C# camel case coverter
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