重写ToString方法的类
class Data
{
public double PointX { get; set; }
public double PointY { get; set; }
public double PointZ { get; set; }
public override string ToString()
{
return string.Format ("X:{0},Y:{1},Z:{2}",this.PointX,this.PointY,this.PointZ);
}
}
客户端调用:
Data data =new Data() { PointX =10,PointY =10,PointZ =10};
string str = data.ToString();
执行的结果str的值为:X:10,Y:10,Z:10