Home Generate range between two strings [AA] -> [CD] or [CCC] -> [DMK]
 I want to generate a sequence of strings between two groups that can be either 1 letter [A] -> [F] , 2 letters such as [AA] -> [CD] or any other length like 3 or 4 letters using c#. For example I can specify the start and end values, and it will generate the sequence. From [AA] to [CD] should generate AA AB AC AD BA BB BC BD CA CB CC CD  I tried to utilize base-26 algorithm to generate the required sequence but failed to get the required output. string from ="AA"; string to = "CD"; IEnumerable mysequence = Enumerable.Range(ConvertNumber(from), ConvertNumber(to) - ConvertNumber(from)).Select(ConvertAlpha).ToList(); public static string ConvertAlpha(int value) { const int a = (int)'A'; value = value - 1; var returnValue = new StringBuilder(); while (value > -1) { var remainder = value % 26; returnValue.Insert(0, (char)(a + remainder)); value = value / 26 - 1; } return returnValue.ToString(); } public static int ConvertNumber(string value) { const int a = (int)'A' - 1; int returnValue = 0; foreach (var character in value.ToUpper()) { returnValue *= 26; returnValue += (int)character - a; } return returnValue; }