Skip to content

Instantly share code, notes, and snippets.

@digitalconceptvisuals
Last active Jul 30, 2020
Embed
What would you like to do?
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