GoGreen PC Tune-Up™
Learn More

Insta-Install™
this is how ssl encrypt our websites
MTNCOMP | List View | Table View | myBlog (1822 Entries)
myBlog Home

Blog


Using C# and generating billions and trillions of unique records using Guid.NewGuid() function instead of Random()

by Mountain Computers Inc, Publication Date: Saturday, June 28, 2025

View Count: 832, Keywords: C Sharp, Trillions, Unique, Hashtags: #CSharp #Trillions #Unique



I had an issue with some ideas regarding billions and trillions of unique records for number theory. It had to do with compression and compaction of the random data.
 
Using the random number serialization that C# was offering and I found another idea of how to use something I have used elsewhere; Guid.NewGuid() - yet now I can interpolate and extrapolate its usefulness for other reasons.
 
using System;
using System.IO;
//using System.Threading.Tasks;
using System.Windows.Forms;
...
Int64 i = 0;
Int64 max = {a really big number};
max = Convert.ToInt64(TxtIterations.Text);
string outputPath = TxtFilename.Text;
...
using (StreamWriter sw = File.AppendText(outputPath)) 
for ( i = 0; i < max; i++) 
{
string w1 = i.ToString() + "," + Guid.NewGuid().ToString();
sw.WriteLine(w1);
}
 
versus another idea:
 
private static readonly Random getrandom = new Random();
 
public static int GetRandomNumber(int min, int max)
{
            lock (getrandom) // synchronize
            {
                return getrandom.Next(min, max);
            }
}
 
example output
 
PS Z:\temp> get-content .\one-hundred-billion.csv -tail 10
35431274537,9fa890d3-0bfa-4352-b984-bff5d05d077c
35431274538,4ee6d12c-f357-4e1f-aa30-adaa758ac092
35431274539,070194e3-d4c9-44c4-8900-b65f88038cd2
35431274540,233f42d4-b751-4e54-bd43-f7ef2ebdbd29
35431274541,26f5ff64-347c-4767-a34a-3c0b58c45529
35431274542,9f3c6d34-2485-4561-8150-0bd5f5f2e2f1
35431274543,8d7fd4be-26fd-40e8-ab0f-a5f3cbd9a33e
35431274544,90726bf4-ad5b-48d5-ab8c-486bb453af87
35431274545,00c4ac61-b42d-4f57-974c-0ce9e89def40
 
with the data from above; one can interpolate, extrapolate and parse quite a bit of randomly generated data into other value sets for various purposes.
 
Use your imagination like I did.
 
more to come...
 
 

if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.

© 2025 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.