Skip to content

Instantly share code, notes, and snippets.

@digitalconceptvisuals
Last active July 30, 2020 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalconceptvisuals/412c784c01aac6dd5cbb91fed2e97411 to your computer and use it in GitHub Desktop.
Save digitalconceptvisuals/412c784c01aac6dd5cbb91fed2e97411 to your computer and use it in GitHub Desktop.
static string camelConverter(string[] words) {
var result = new StringBuilder();
// First word is lower
result.Append(
words[0]
.Trim()
.ToLower()
);
// Subsequent words are Proper case
for (var offset = 1;
offset < words.Length;
offset++)
{
// First letter is uppercase
result.Append(
words[offset]
.Substring(0, 1)
.ToUpper());
// Rest of the letters are lowercase
result.Append(
words[offset].
Substring(1).
ToLower());
}
return result.ToString();
}
static string lowerConverter(params string[] words) {
// Accumulate result in StringBuilder
var result = new StringBuilder();
// Every word is converted to lower
// And concatenated
foreach (var word in words)
{
result.Append(
word
.Trim()
.ToLower());
}
return result.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment