C# 重写ToString()方法输出私有变量的代码片段
public class MyClass { private string customer =""; private int customerID = 0; public string Customer { get { return customer; } set { customer = value; } } public int CustomerID { get { return customerID; } set { customerID = value; } } public override string ToString() { return string.Format ("Customer = {0} ID = {1}", Customer, CustomerID); } }