Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8320945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:50:39+00:00 2026-06-08T22:50:39+00:00

Trying to build upon the answers in this thread [ Alphanumeric Counter ] to

  • 0

Trying to build upon the answers in this thread [ Alphanumeric Counter ] to build an endless (for any int) alphanumeric counter without padding.

I want to create a counter that starts at 0 and counts something like this.

0,1,2…Y,Z,10,11,12…1Y,1Z,20,21…ZY,ZZ,100,101…ZZZ,1000,1001 .. infinity (overflow)….

The purpose of the counter is to create short URLS from my database INT id’s. I want to input the id of the row and get a base 36 value from it that i can use as the url.

I’ve made a few attempts but they all seem to end up wrong. I’m getting stuck on how I can test when I should increase the number of characters. i.e. go from Z to 10 or from ZZ to 100.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:50:40+00:00Added an answer on June 8, 2026 at 10:50 pm

    I think this is what you want:

    using System;
    using System.Collections.Generic;
    
    class Test
    {
        static void Main()
        {
            foreach (string x in EndlessBase64Sequence())
            {
                Console.WriteLine(x);
            }
        }
    
        private static char NextBase36Char(char c)
        {
            if ((c >= '0' && c <= '8') ||
                (c >= 'A' && c <= 'Z'))
            {
                return (char) (c + 1);
            }
            if (c == '9')
            {
                return 'A';
            }
            throw new ArgumentException();
        }
    
        public static IEnumerable<string> EndlessBase64Sequence()
        {
            char[] chars = { '0' };
    
            while (true)
            {
                yield return new string(chars);
    
                // Move to the next one...
                bool done = false;
                for (int position = chars.Length - 1; position >= 0; position--)
                {
                    if (chars[position] == 'Z')
                    {
                        chars[position] = '0';
                    }
                    else
                    {
                        done = true;
                        chars[position] = NextBase36Char(chars[position]);
                        break;
                    }
                }
                // Need to expand?
                if (!done)
                {
                    chars = new char[chars.Length + 1];
                    chars[0] = '1';
                    for (int i = 1; i < chars.Length; i++)
                    {
                        chars[i] = '0';
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I stumbled upon this while trying to build an ActiveX dll from an old
I have a simple jQuery script that I'm trying to build upon but I
Trying to build openssl-fips-2.0 with NDK, before I was lucky found this link and
** New EDIT ** so what I'm trying to do is this. I want
I am trying to build an appliction based upon the pcredemo application. When I
In Visual Studio 2010, I'm trying to build an COM-interop enabled C# project without
Upon trying to build the page Default.aspx I get the error: Error 5 Could
I'm trying to set up a Maven project so that it will build upon
I am trying to build a helper to create a simple single level menu.
Upon trying to build even the simplest Metro application in Visual Studio, I get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.