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

  • SEARCH
  • Home
  • 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 7838697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:10:54+00:00 2026-06-02T15:10:54+00:00

I have the a function I took from this post which works great: private

  • 0

I have the a function I took from this post which works great:

private string GenerateTransactionCode()
{
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    var random = new Random();
    var result = new string(
        Enumerable.Repeat(chars, 8)
                  .Select(s => s[random.Next(s.Length)])
                  .ToArray());
    return result;
}

I would like to modify it so that instead of it being random, it picks the alpha numeric digits based on DateTime.UtcNow.Ticks. This way it will be non-repeating. I suppose the characters in the resulting TransactionCode might need to be increased depending on the length of the milliseconds? I would like the length of the resulting TransactionCode to be constant. Hopefully, no more than 8 Characters.

Example: If the ticks happened to be 135 (going to me more than that in real life) then the resulting code will be ACE or BDF depending if it’s 0 based (I don’t care if it is or not).

  • 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-02T15:10:56+00:00Added an answer on June 2, 2026 at 3:10 pm

    I imagine what you actually want is a real non-repeating transaction code, or GUID:

    Guid g = Guid.NewGuid();
    string txcode = Convert.ToBase64String(g.ToByteArray());
    

    If you want to clean it up:

    txcode = txcode.Replace("=","").Replace("+","").Replace("/","");
    

    Example of generated output is OEndimZwsEKRAbAwnvzjoA but because of the replacement of + / and = the length can be slightly unpredictable.

    You may prefer this format g.ToString("N") which gives something like 58d5381c878b484591568b086296fe8e and is guaranteed to be 32 characters long.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I took this from Google Code Playground http://code.google.com/apis/ajax/playground/ /*CLOSURE * When a function is
I have a script of snow for the site, I took it from this
I have this modified code example I took from the wikipedia article on anonymous
I'm facing a problem with IE6. I took the toggle function from this website
I have function some_func_1 which will create an object of type some_type and will
I have function like this: function gi_insert() { if(!IS_AJAX){ $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Naslov', 'trim|required|strip_tags'); $this->form_validation->set_rules('body',
I have created a test (not real) encryption function which takes a byte[] and
I have something like this and it has been created from jQuery .append(html) <div
I am trying to implement a simpler version of this algorithm but which works
I have a function which goes forward 1 utf-8 character and returns the number

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.