b******y 发帖数: 139 | 1 Suppose I have a class as follows,
public class C
{
int id;
string name;
double amount;
public void ClassToDatarow(ref datarow r)
{
r["id"] = this.id;
r["name"] = this.name;
r["amount"] = this.amount;
}
}
Class C may have many attributes, every time I make a change to the
attributes I have to do the same to the function. Can I use some iteration
to finish the ClassToDatrow job without writing all r["var"]= this.var? | L*********r 发帖数: 92 | 2 看看Type class 和参照下面的link.
http://msdn2.microsoft.com/en-us/library/66btctbe.aspx
【在 b******y 的大作中提到】 : Suppose I have a class as follows, : public class C : { : int id; : string name; : double amount; : public void ClassToDatarow(ref datarow r) : { : r["id"] = this.id; : r["name"] = this.name;
|
|