Created
December 20, 2012 09:10
-
-
Save webgio/4344033 to your computer and use it in GitHub Desktop.
Lexicographical next string, to use for autocomplete searches with startkey and endkey parameters. (CouchDb, Azure Storage tables ... )
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 LexicographicallyNextString(string starting) | |
{ | |
starting = starting.ToLowerInvariant(); | |
char last = starting[starting.Length - 1]; | |
int position = last; | |
int next = ++position; | |
char nextChar = (char)next; | |
string endStarting = starting.Substring(0, starting.Length - 1) + nextChar.ToString(); | |
return endStarting; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment