首先T是我的一个实体类
public static void InsertIntoGather<T>(List<T> list) where T : new()
{
try
{
foreach (T info in list)
{
//我想在这获取T中字段值.....
HZ.Data.DAL_Helper.InsertModel<T>(info);
}
}
catch (Exception err) { GatherLog.WritePrivateProfileString("数据访问错误:", "InsertIntoGather", err.ToString(), Application.StartupPath + "\\log.ini"); }
}
断点信息如下:
list
Count = 15
[0]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[1]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[2]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[3]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[4]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[5]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[6]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[7]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[8]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[9]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[10]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[11]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[12]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[13]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[14]: {Info.DataGather.Model.Tb_JKouMedicine_organ}而每一个里面是
list.ToArray()[0]
{Info.DataGather.Model.Tb_JKouMedicine_organ}
orgarncode: "5613"
orgarnname: "盐酸乙哌立松 (H20030102 Eisai Co.,Ltd 86979086000242)"我想取出orgarncode怎么做你??
public static void InsertIntoGather<T>(List<T> list) where T : new()
{
try
{
foreach (T info in list)
{
//我想在这获取T中字段值.....
HZ.Data.DAL_Helper.InsertModel<T>(info);
}
}
catch (Exception err) { GatherLog.WritePrivateProfileString("数据访问错误:", "InsertIntoGather", err.ToString(), Application.StartupPath + "\\log.ini"); }
}
断点信息如下:
list
Count = 15
[0]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[1]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[2]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[3]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[4]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[5]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[6]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[7]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[8]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[9]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[10]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[11]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[12]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[13]: {Info.DataGather.Model.Tb_JKouMedicine_organ}
[14]: {Info.DataGather.Model.Tb_JKouMedicine_organ}而每一个里面是
list.ToArray()[0]
{Info.DataGather.Model.Tb_JKouMedicine_organ}
orgarncode: "5613"
orgarnname: "盐酸乙哌立松 (H20030102 Eisai Co.,Ltd 86979086000242)"我想取出orgarncode怎么做你??
{
if(info is Info.DataGather.Model.Tb_JKouMedicine_organ)
{
var value = ((Info.DataGather.Model.Tb_JKouMedicine_organ)info).orgarncode
}
}其实这样用泛型方法没啥意思...
{
if(T is yourType)
{
yourType t= T as yourType;
t.orgarncode.....
t.orgarnname.....
}
//我想在这获取T中字段值.....
HZ.Data.DAL_Helper.InsertModel<T>(info);
}
t.orgarnname.....
是多少呢,我最终还是要从list里面取的啊
是吧》??PS
你都升星星了!我倒!