using System;
using System.Collections.Generic;
// A GUID (Globally Unique Identifier) and a UUID (Universally Unique Identifier)
// are essentially the same, both being 128-bit values used to uniquely identify
// information in computer systems.
public class HashGuidsExample
{
public static void Main(string[] args)
{
// Create a HashSet containing three randomly generated GUIDs.
// Guid.NewGuid() produces a type‑4 GUID.
var guids = new HashSet<Guid> {
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid()
};
// Compute a hash value for the entire set.
// HashCode.Combine(...) is idiomatic C# for combining values into a single hash.
int hash = HashCode.Combine(guids);
// Print the GUIDs so we can see what was hashed.
Console.WriteLine("GUIDs in the set:");
foreach (var g in guids) {
Console.WriteLine(g);
}
// Print the resulting hash value.
Console.WriteLine("\nHash of the GUID set: " + hash);
}
}
/*
run:
GUIDs in the set:
e0b30131-cfe2-41f9-ae35-f7636b5547ac
f8265c82-2dd7-43ce-bbd4-e7a2d89ea432
cd1f53d9-2138-4f8e-89a5-1303dc337ceb
Hash of the GUID set: 1876608298
*/