c# - Using LINQ to convert array object[,] to array -
i have information external system return me in following format:
i required convert information object[,] array split on "|". i'm been using linq in vb information:
dim vsapdatatemp(,) object = local_saptabledata.data dim vlinq = tempresult in vsapdatatemp select value = array.convertall(tempresult.tostring.split(rfc_delimiterchar), function(vval) cobj(vval.tostring.trim)) dim vnewsapdata() object = vlinq.toarray
but i'm moving c# , i'm stuck following error:
when using code:
var vsapdatatemp = local_saptabledata.data; local_saptabledata.freetable(); fw.gccleaner(); local_saptabledata = null; var vlinq = (from tempresult in (vsapdatatemp object[,]) select string strvalue = array.convertall(tempresult.split(stcvariables.strsaprfcdelimiterchar), vval => (vval object).tostring().trim())); var vnewsapdata = vlinq.toarray<string>();
what (if any) workaround exists issue?
you have use cast
call:
from tempresult in (vsapdatatemp object[,]).cast<object>() (...)
that's because object[,]
implements non-generic ienumerable
doesn't work linq. (i have no clue why works in vb.net begin with).
Comments
Post a Comment