Skip to content

Instantly share code, notes, and snippets.

@MelbourneDeveloper
Created October 17, 2020 04:29
Show Gist options
  • Select an option

  • Save MelbourneDeveloper/f5ea258897648e9796eb6e36f6beb193 to your computer and use it in GitHub Desktop.

Select an option

Save MelbourneDeveloper/f5ea258897648e9796eb6e36f6beb193 to your computer and use it in GitHub Desktop.
Expressions Vs Statements
public static string ToUppercaseExpression(this string currentString) =>
new string(currentString.Select(c => (char)(c < 97 || c > 122 ? c : c - 32)).ToArray());
public static string ToUppercaseStatements(this string currentString)
{
var returnValue = new StringBuilder();
foreach(var c in currentString)
{
if(c < 97 || c > 122)
{
returnValue.Append(c);
}
else
{
returnValue.Append((char)(c - 32));
}
}
return returnValue.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment