Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi...

I want to generate a unique sequence of numbers in this fashion...

1, 2, 3, ...9, A , B...Z, 10, 11, 12, 13, ......19, 1A, 1B.......1Z, 20, 21......ZZZZZZZZZZ in 10 digits.

Similar to the hexadecimal series but till Z ...

I guess something inbuilt mechanism exist in .NET to generate this series. But I dont have a name to research about it.

I can write my own code to generate this sequence, but I always prefer to use the .net built in constructs than a custom code.

Can anybody guide me in this direction.. particularly, what this sequence is called as and is any built in construct available for generating this in .net ???
Posted
Comments
Aarti Meswania 27-May-13 8:58am    
after 19 1A to 1z not 1a to 19z then 20?
which series ou want to generate exactly?
bbirajdar 27-May-13 9:09am    
A small change in your statement.. from 19, 1A to 1Z..not 19Z...
bbirajdar 27-May-13 9:10am    
similar to hexadecimal , but till Z and not F ...
bbirajdar 27-May-13 14:24pm    
Thank you and + 5 for spending time to help me

Nothing built in for base-36, but there are things like this if you search the net:

Base 36 type for .NET (C#)[^]

The number of digits represents the biggest number you will have, a 10 digit base-36 number is very very large.
 
Share this answer
 
Comments
bbirajdar 27-May-13 14:26pm    
Thanks Ron ..5ed for your efforts
I doubt there is a 'built in construct' for this. You may very easily generate yourself such a sequence.

[Update]
Quote:
if you have any solution for this, please provide me
Albeit this is a bit in contrast with:
Quote:
I can write my own code to generate this sequence



Here we go...

C#
class SeqGen
{
  char [] code;

  public SeqGen()
  {
      code = new char[10];
      for(int n=0; n<10; n++) code[n]='0';
  }

  private void inc(int pos)
  {

    if (code[pos] == '9')
        code[pos] = 'A';
    else if (code[pos]=='Z')
    {
      if ( pos==0)
        throw new Exception("overflow");
      code[pos] = '0';
      inc(pos-1);
    }
    else
    {
      code[pos]++;
    }
  }

  public void inc()
  {
    inc(9);
  }
  public  override string ToString()
  {
     return new string(code).TrimStart(new char [] {'0'});
  }
}


Usage example:
C#
class Program
 {
   static void Main()
   {
     SeqGen sg = new SeqGen();
     for (int i = 0; i < 100; i++)
     {
       sg.inc();
       Console.WriteLine("i={0}, code={1}", i, sg.ToString());
     }
   }
 }


[/Update]
 
Share this answer
 
v4
Comments
bbirajdar 27-May-13 9:54am    
Thank you very much CPallini.. This worked perfectly for me...I wish I could have voted you 100 stars
CPallini 27-May-13 13:56pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900