Simple algorithm

Just thought I'd share the simplest little algorithm ever with you guys. I created this little cutey for the blogging part of my personal site (coming soon ;) - I use it for generating unique, semi-sequential identifiers for my blog posts...

public static string GenerateId()

{

    string ticks = DateTime.Now.Ticks.ToString();

    string temp = "";

 

    for ( int i = 0; i < ticks.Length; i++ )

    {

        if ( ( i % 3 ) == 0 )

        {

            temp += ticks[i];

        }

    }

 

    return temp;

}

 

Published Saturday, February 05, 2005 7:01 AM by Aylar
Filed under: ,

Comments

# re: Simple algorithm

Friday, February 04, 2005 4:24 PM by Eric Newton
so its only five digits?

# re: Simple algorithm

Friday, February 04, 2005 4:29 PM by Eric Newton
ah snippetcompiler let me see this algo. interesting.

# re: Simple algorithm

Friday, February 04, 2005 5:06 PM by Thomas Johansen
>> so its only five digits?

Currently I am getting 6 digits.

# re: Simple algorithm

Friday, June 08, 2007 2:10 AM by xc

xcxc

Leave a Comment

(required) 
(required) 
(optional)
(required)