3 public class ValueType1
7 Blah a = new Blah ("abc", 1);
8 Blah b = new Blah ("ab" + 'c', 1);
10 start = Environment.TickCount;
12 start = Environment.TickCount;
13 for (int i = 0; i < 1000000; i++)
15 end = Environment.TickCount;
16 Console.WriteLine ("struct common GetHashCode(): {0}", end-start);
18 start = Environment.TickCount;
19 for (int i = 0; i < 1000000; i++)
21 end = Environment.TickCount;
22 Console.WriteLine ("struct common Equals(): {0}", end-start);
24 Blah2 a2 = new Blah2 ("abc", 1);
25 Blah2 b2 = new Blah2 ("abc", 1);
26 start = Environment.TickCount;
27 for (int i = 0; i < 1000000; i++)
29 end = Environment.TickCount;
30 Console.WriteLine ("struct specific GetHashCode(): {0}", end-start);
32 start = Environment.TickCount;
33 for (int i = 0; i < 1000000; i++)
35 end = Environment.TickCount;
36 Console.WriteLine ("struct specific Equals(): {0}", end-start);
46 public Blah (string s, int k)
58 public Blah2 (string s, int k)
64 public override int GetHashCode () {
65 return i ^ s.GetHashCode ();
67 public override bool Equals (object obj) {
68 if (obj == null || !(obj is Blah2))
71 return b.s == this.s && b.i == this.i;