110,536
社区成员
发帖
与我相关
我的任务
分享
StuInfoEntity entity = new StuInfoEntity();
entity = new StuInfoEntity();
entity.Id = int.Parse(dt.Rows[i]["ID"].ToString());
entity.Number = dt.Rows[i]["Number"].ToString();
entity.Name = dt.Rows[i]["Name"].ToString();
entity.Sex = dt.Rows[i]["Sex"].ToString();
entity.Address = dt.Rows[i]["Address"].ToString();
entity.PostNum = dt.Rows[i]["PostNum"].ToString();
entity.PhoneNum = dt.Rows[i]["PhoneNum"].ToString();
entity.Political = dt.Rows[i]["Political"].ToString();
entity.IdCard = dt.Rows[i]["IDCard"].ToString();
entity.IsThreeGood = dt.Rows[i]["IsThreeGood"].ToString();
entity.CountryScholarship = dt.Rows[i]["CountryScholarship"].ToString();
entity.InstituteScholarship = dt.Rows[i]["InstituteScholarship"].ToString();
entity.Reward = dt.Rows[i]["Reward"].ToString();
entity.Punish = dt.Rows[i]["Punish"].ToString();
entity.ClassId = int.Parse(dt.Rows[i]["ClassId"].ToString());
entity.IsPoor = dt.Rows[i]["IsPoor"].ToString();
entity.IsCountrySide = dt.Rows[i]["IsCountrySide"].ToString();
entity.Note = dt.Rows[i]["Note"].ToString();
if(propertyInfo.PropertyType.IsEnum)
{
propertyInfo.SetValue(targetObj,Enum.ToObject(propertyInfo.PropertyType,reader.GetValue(i)),null);
}
public class Program
{
static void Main(string[] args)
{
StuInfoEntity obj = new StuInfoEntity();
Type t = typeof(StuInfoEntity);
PropertyInfo[] myPropertyInfo;
// Get the properties of 'Type' class object.
myPropertyInfo = t.GetProperties();
for (int i = 0; i < myPropertyInfo.Length; i++)
{
myPropertyInfo[i].SetValue(obj, i.ToString(), null);
Console.WriteLine(myPropertyInfo[i].GetValue(obj,null));
}
Console.ReadKey();
}
}
public class StuInfoEntity
{
public string a, b, c;
public string A
{
set
{
a = value;
}
get
{
return a;
}
}
public string B
{
set {
b = value;
}
get
{
return b;
}
}
public string C
{
set
{
c = value;
}
get
{
return c;
}
}
}
}