March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System; namespace Samples { public struct ValueTypeSample { private struct Point { private int xValue; private int yValue; public int X { get { return xValue;} set {xValue = value;}} public int Y { get { return yValue;} set {yValue = value;}} public override bool Equals(object o) { if(!(o is Point)) return false; Point p = (Point) o; return this.xValue == p.xValue && this.yValue == p.yValue; } public override string ToString() { return string.Format("Point: X: {0}, Y: {1}", X, Y); } public override int GetHashCode() { return xValue ^ yValue; } } public static void Main() { Point p = new Point(); Console.WriteLine("p.ToString(): {0}", p.ToString()); Console.WriteLine("p.Equals(new Point()): {0}", p.Equals(new Point())); Console.WriteLine("p ...Read now
Unlock full access