ShortGuid - A shorter and url friendly GUID class in C#

Using the ShortGuid
The ShortGuid is compatible with normal Guid's and other ShortGuid strings. Let's see an example:

Guid guid = Guid.NewGuid();

ShortGuid sguid1 = guid; // implicitly cast the guid as a shortguid

Console.WriteLine( sguid1 );

Console.WriteLine( sguid1.Guid );

This produces a new guid, uses that guid to create a ShortGuid, and displays the two equivalent values in the console. Results would be something along the lines of:

FEx1sZbSD0ugmgMAF_RGHw
b1754c14-d296-4b0f-a09a-030017f4461f

Or you can implicitly cast a string to a ShortGuid as well.

string code = "Xy0MVKupFES9NpmZ9TiHcw";

ShortGuid sguid2 = code; // implicitly cast the string as a shortguid

Console.WriteLine( sguid2 );

Console.WriteLine( sguid2.Guid );

Which produces the following:

Xy0MVKupFES9NpmZ9TiHcw
540c2d5f-a9ab-4414-bd36-9999f5388773

Read More ......

http://www.singular.co.nz/blog/archive/2007/12/20/shortguid-a-shorter-and-url-friendly-guid-in-c-sharp.aspx

Comments

Popular posts from this blog

Understanding Top line and Bottom line?

How to activate PF UAN account

Scrum Master vs Product Owner