Skip to content

Instantly share code, notes, and snippets.

@Himura2la
Created June 25, 2019 15:11
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 Himura2la/116ce976dcbdc8069019d67e1f02e50d to your computer and use it in GitHub Desktop.
Save Himura2la/116ce976dcbdc8069019d67e1f02e50d to your computer and use it in GitHub Desktop.
StringRunner
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