enum Color { Red, Green, Blue } Color c = Color.Blue; int hashCode = c.GetHashCode(); Console.WriteLine("Hash code for the color blue: " + hashCode);
enum Size { Small = 1, Medium = 2, Large = 3 } Size s = Size.Large; int hashCode = s.GetHashCode(); Console.WriteLine("Hash code for the size large: " + hashCode);This example defines an enum `Size` with three values and assigns integer values to each member. It creates an instance of the `Size` enum named `s` with a value of `Size.Large`. The `GetHashCode()` method is called on `s`, which returns the hash code for the `Size.Large` enum value. The hash code is printed to the console. The System.Enum.GetHashCode() method is part of the System.Runtime.dll library.