class Program
{
static void Main(string[] args)
{
Car car1 = new Car();
car1.Make = "Oldsmobile";
car1.Model = "Cultas Supreme";
Car car2 = new Car();
car2.Make = "GEO";
car2.Model = "Prism";
Dictionary<string, Car> myDicitionary = new Dictionary<string, Car>();
myDicitionary.Add(car1.Model, car1);
myDicitionary.Add(car2.Model, car2);
foreach (KeyValuePair<string, Car> CAR in myDicitionary)
{
Console.WriteLine("{0}-- {1}", CAR.Key,CAR.Value);
}
Console.ReadLine();
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
}
}
输出结果
Cultas Supreme-- Collection.Programe+Car Prism--
集合.程序+汽车
但为什么它不显示 Car 而不是 Collection.Programe+Car 的值`