generate random serial number in csharp

One way to generate a random serial number in C# is to use the Guid class, which generates unique identifiers. Here's an example:

main.cs
Guid randomSerialNumber = Guid.NewGuid();
string serialNumberString = randomSerialNumber.ToString("N"); // convert to a string without hyphens
143 chars
3 lines

The resulting serialNumberString will be a random string of 32 hexadecimal digits (i.e. 128 bits) with no hyphens. This should be unique enough for most purposes.

gistlibby LogSnag