May 2010
Intermediate to advanced
1752 pages
41h 17m
English
As you recall from Chapter 6, System.Object defines a member named MemberwiseClone(). This method is used to obtain a shallow copy of the current object. Object users do not call this method directly as it is protected. However, a given object may call this method itself during the cloning process. To illustrate, create a new Console Application named CloneablePoint that defines a class named Point:
// A class named Point.
public class Point
{
public int X {get; set;}
public int Y {get; set;}
public Point(int xPos, int yPos) { X = xPos; Y = yPos;}
public Point(){}
// Override Object.ToString().
public override string ToString()
{ return string.Format("X = {0}; Y = {1}", X, Y ); }
}
Given what you ...