我在WCF中的第一个模型
public class One
{
public string A { get; set; }
public string B { get; set; }
}我的第二个
public class Two : One
{
public string C { get; set; }
}现在我有了Model 2的属性的值,如下所示
Two obj = new Two()
{
A="ww",
B="WWW",
C="EE"
};
One obj1 = new One();现在,我想将我的obj对象值复制到obj1。但是在复制first object ..How时,我需要跳过第三个值吗?
发布于 2015-12-23 15:43:20
您可以为One创建复制构造函数
public class One
{
public One(One other)
{
A = other.A;
B = other.B;
}
public string A { get; set; }
public string B { get; set; }
}并像这样使用它:
Two two = new Two
{
A="ww",
B="WWW",
C="EE"
};
One one = new One(two);https://stackoverflow.com/questions/34430883
复制相似问题