在我的“业务对象”中显示“管理表”的正确方法是什么?我的地址对象上有以下内容。
public class Address
{
public int AddressID { get; set; }
public KeyValuePair<short, string> County { get; set; }
...
}
现在我将如何实例化这个对象,就KeyValuePair<,>
属性而言?
我的猜测是:
var myAddress = new Address { AddressID = 3, County = new KeyValuePair<short, string>(32, "La Crosse")}
编辑
这就是我用KeyValuePair<>
另一位程序员的建议所取代的。
.....Address.cs.....
public County County { get; set; }
.....County.cs.....
public class County
{
public short? CountyID { get; set; }
public string CountyName { get; set; }
}
两者之间是否有更好的方法或第三种更好的方法?