我的项目中有这些类:
public class A
{
public A(B b, C c)
{
this.b = b;
this.c = c;
}
B b;
C c;
}
public class B
{
public B(DataRow row)
{
if (row.Table.Columns.Contains("Property3 "))
this.Property3 = row["Property3 "].ToString();
if (row.Table.Columns.Contains("Property4"))
this.Property4= row["Property4"].ToString();
}
public string Property3 { get; set; }
public string Property4{ get; set; }
public object MyToObject()
{
}
}
public class C
{
public C(DataRow row)
{
if (row.Table.Columns.Contains("Property1 "))
this.Property1 = row["Property1 "].ToString();
if (row.Table.Columns.Contains("Property2 "))
this.Property2 = row["Property2 "].ToString();
}
public string Property1 { get; set; }
public string Property2 { get; set; }
}
我想将一个对象作为MyToObject
类中声明的函数的输出A
;该输出对象包含 and 的所有属性b
,c
如下所示:
output object = {b.Property3 , b.Property4 , c.Property1 , c.Property2 }