湖上湖
这个问题缺少更多的上下文信息,大概写了下,不知是否正确,供参考。123456789101112131415161718192021222324252627282930313233343536373839404142434445464748using System; namespace Car{ class Car { //将品牌、型号、颜色、价格定义为属性 public string Brand { get; set; } public string Model { get; set; } public string Color { get; set; } public decimal Price { get; set; } //构造函数 public Car(){ } //显示汽车信息 public override string ToString() { return String.Format("品牌:{0}, 型号:{1}, 颜色:{2}, 价格:{3}.",Brand,Model,Color,Price); } } class Program { //控制台测试: static void Main(string[] args) { Car car1 = new Car(); car1.Brand = "奔驰"; car1.Model = "SLR722"; car1.Color = "黑色"; car1.Price = 100.00m; Console.WriteLine("汽车1的信息为-{0}",car1.ToString()); Car car2 = new Car() { Brand = "宝马", Model = "X0", Color = "银色", Price = 120.00m, }; Console.WriteLine("汽车2的信息为-{0}", car2.ToString()); Console.ReadKey(); } }}