13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C#</strong> LANGUAGE SPECIFICATION}if (GetType() == o.GetType()) {Point p = (Point)o;return (X == p.X) && (Y == p.Y);}return false;/// Report a point's location as a string./// A string representing a point's location, in the form (x,y),/// without any leading, training, or embedded whitespace.public override string ToString() {return "(" + X + "," + Y + ")";}/// This operator determines whether two Points have the same/// location./// p1 is the first Point to be compared./// p2 is the second Point to be compared./// True if the Points have the same location and they have/// the exact same type; otherwise, false./// /// public static bool operator==(Point p1, Point p2) {if ((object)p1 == null || (object)p2 == null) {return false;}if (p1.GetType() == p2.GetType()) {return (p1.X == p2.X) && (p1.Y == p2.Y);}}}return false;}/// This operator determines whether two Points have the same/// location./// p1 is the first Point to be compared./// p2 is the second Point to be compared./// True if the Points do not have the same location and the/// exact same type; otherwise, false./// /// public static bool operator!=(Point p1, Point p2) {return !(p1 == p2);}/// This is the entry point of the Point class testing/// program./// This program tests each method and operator, and/// is intended to be run after any non-trvial maintenance has/// been performed on the Point class.public static void Main() {// class test code goes here}E.4.2 Resulting XMLHere is the output produced by one documentation generator when given the source code for class Point, shownabove:446

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!