fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. var luxembourg = new Country { Name = "Luxembourg", CapitalName = "Luxembourg" };
  8. var singapore = new Country { Name = "Singapore", CapitalName = "Singapore" };
  9.  
  10. Console.WriteLine("Luxembourg: " + luxembourg.GetHashCode());
  11. Console.WriteLine("Singapore: " + singapore.GetHashCode());
  12. }
  13. }
  14.  
  15. class Country
  16. {
  17. public string Name { get; set;}
  18. public string CapitalName { get; set;}
  19.  
  20. public override int GetHashCode()
  21. {
  22. return Name.GetHashCode() ^ CapitalName.GetHashCode();
  23. }
  24. }
Success #stdin #stdout 0.02s 33920KB
stdin
Standard input is empty
stdout
Luxembourg: 0
Singapore: 0