• Как генерировать/перебирать строку в пределах диапазона?

    @cicatrix
    было бы большой ошибкой думать
    А алфавит-то какой? 0-9A-Z, 0-9A-z, 0-9A-F или ещё какой?
    Может 4-й разряд принимать буквенные значения? Для каждого разряда разные алфавиты?

    class ComplexValue
        {
            const string m_Alphabet = "abcdefghijklmnopqrstuvwxyz";
            int First { get; set; }
            char[] Middle { get; set; };
            int Last { get; set; }
            public ComplexValue(string input)
            {
                First = int.Parse(input.Substring(0, 1));
                Middle = input.Substring(1, 3).ToCharArray();
                Last = int.Parse(input.Substring(input.Length - 1, 1));
            }
    
            public string Value() => $"{First}{new string(Middle)}{Last}";
    
            private int IncrementLast()
            {
                Last++;
                if (Last > 9) { Last = 0; return 1; }
                return 0;
            }
    
            private int DecrementLast()
            {
                Last--;
                if (Last < 0) { Last = 9; return 1 }
                return 0;
            }
    
            private char IncrementChar(char c, out bool carry)
            {
                carry = false;
                c++;
                if (c > m_Alphabet[m_Alphabet.Length -1] )
                {
                    c = m_Alphabet[0];
                    carry = true;
                }
                return c;
            }
    
            private char DecrementChar(char c, out bool borrow)
            {
                borrow = false;
                c--;
                if (c < m_Alphabet[0])
                {
                    c = m_Alphabet[m_Alphabet.Length - 1];
                    borrow = true;
                }
                return c;
            }
            
            private int IncrementMiddle()
            {
                int pos = Middle.Length - 1;
                while (pos > 0)
                {
                    Middle[pos] = IncrementChar(Middle[pos], out bool carry);
                    if (!carry) return 0;
                    pos--;
                }
                return 1;
            }
    
            private int DecrementMiddle()
            {
                int pos = Middle.Length - 1;
                while (pos > 0)
                {
                    Middle[pos] = DecrementChar(Middle[pos], out bool borrow);
                    if (!borrow) return 0;
                    pos--;
                }
                return 1;
            }
    
            public void Increment()
            {
                if (IncrementLast() > 0)
                {
                    if (IncrementMiddle() > 0) First++;
                }
            }
    
            public void Decrement()
            {
                if (DecrementLast() > 0)
                {
                    if (DecrementMiddle() > 0) First--;
                }
            }
        }
    Ответ написан