c# - DataTable AsEnumerable().ToList i can not make it work -
i can not create work. should create work ? give thanks you
public static list<int> lstallmonsterids = new list<int>(); using (datatable dttemp = dbconnection.db_select_datatable("select myid,name mytable")) { lstallmonsterids = dttemp.asenumerable().tolist(dtr => convert.toint32(dtr.field<int16>("pokemonid").tostring())); }
you need list<int> back, select field using int, , don't phone call tostring on it, , in end phone call tolist
lstallmonsterids = dttemp.asenumerable() .select(dtr => dtr.field<int>("myid")) .tolist(); if field of type int16, can implicitly casted int or int32, don't have phone call tostring on , convert int32
c# linq
No comments:
Post a Comment