Redian新闻
>
How to use reflection in C# to do this job?
avatar
How to use reflection in C# to do this job?# Programming - 葵花宝典
b*y
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?
avatar
L*r
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;

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。