Created
June 25, 2019 15:11
-
-
Save Himura2la/116ce976dcbdc8069019d67e1f02e50d to your computer and use it in GitHub Desktop.
StringRunner
This file contains hidden or 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
public static string StringRunner(string s) { | |
var output = new StringBuilder(); | |
for(int i = 0; i < s.Length; i++) { | |
char prevCh = i > 0 ? s[i - 1] : '\0'; | |
char thisCh = s[i]; | |
char nextCh = i < s.Length - 1 ? s[i + 1] : '\0'; | |
switch(thisCh) { | |
// Do the replacements | |
default: | |
output.Append(thisCh); | |
break; | |
} | |
} | |
return output.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment