我有一个接口,它有另一个接口作为其属性:
public interface IUserContactInformation
{
bool IsDefaultContactInformation { get; set; }
ICity City { get; set;
}
public interface ICity
{
int Id { get; set; }
string Name { get; set; }
}
和班级
public class City : ICity
{
public int Id { get; set; }
public string Name { get; set; }
public IRegion Region { get; set; }
public static City ConvertFromModel(CityLimited modelCity)
{
City city = new City();
city.Id = modelCity.Id;
city.Name = modelCity.Name;
return city;
}
我现在如何初始化城市名称?
当我使用
时ICity city = new City();
我明白了:
不能隐含转换类型..
我也试过
IUserContactInformation contact = new IUserContactInformation();
contact.City.Name = model.City;
但是我收到了错误