我有 2 节课:
public class Place
{
public string GoogleReference { get; set; }
public string GoogleID { get; set; }
public string Name { get; set; }
public string Vicinity { get; set; }
}
public class PlaceDetail : Place
{
public string Url { get; set; }
public string InternationalPhoneNumber { get; set; }
public string Website { get; set; }
}
如何将 Place 转换为 PlaceDetail?下一个代码不起作用
Place place = new Place();
place.Name = "A";
....
PlaceDetail placeDetail = (PlaceDetail)place;
无法将“PlacesLibrary.Place”类型的对象转换为“PlacesLibrary.PlaceDetail”类型。