-
-
Save digitalconceptvisuals/412c784c01aac6dd5cbb91fed2e97411 to your computer and use it in GitHub Desktop.
This file contains 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
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