Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
C sharp vs real basic
//taking in thomasz suggestions
static void Main(string[] args)
Dictionary<String, String> nDic = new Dictionary<String, String>();
int i;
var enc = Encoding.GetEncoding("iso-8859-1");
Random rnd = new Random();
Int64 tTimer = DateTime.Now.Ticks;
for (i = 1; i <= 1000000; i++)
var pUUIDBytes = new byte[16];
// Generate a random UUID
var pUUID = enc.GetString(pUUIDBytes);
//Check if pUUID exists in the dictionary
if (!nDic.ContainsKey(pUUID))
//If not, add it to the dictionary
nDic.Add(pUUID, pUUID);
tTimer = DateTime.Now.Ticks - tTimer; //Stop the clock!
Console.WriteLine("Operation completed in " + ((double)tTimer / (double)TimeSpan.TicksPerSecond).ToString() + " seconds");
Console.WriteLine(nDic.Count.ToString() + " keys in dictionary");
//Keep the window open at the end of the test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment