c# - Can't Modify Dictionary Value -
i've been using code try , modify data written file, no matter do, directly assigning null bytes, won't change. trying access dictionary entry seperate class 1 generated in.
buffer.blockcopy( pio.getbuffer(), 0, wat.settingentrylist[0x63e83fff].data, 0, wat.settingentrylist[0x63e83fff].data.length); buffer.blockcopy( pio.getbuffer(), wat.settingentrylist[0x63e83fff].data.length, wat.settingentrylist[0x63e83ffe].data, 0, wat.settingentrylist[0x63e83ffe].data.length);
here variable in class, how initialized dictionary:
public class settingentry { public byte[] data { get; set; } }
public dictionary settingentrylist = new dictionary();
when writing data file, go through each key so:
foreach (keyvaluepair<int, settingentry> se in settingentrylist) { pio.writebytes(se.value.data); }
i have gone through , debugged. once sure key existed , all, used code, in when ran, application stayed in loop until exited:
while (gpd.settingentrylist[0x63e83fff].data != new byte[gpd.settingentrylist[0x63e83fff].data.length]) gpd.settingentrylist[0x63e83fff].data = new byte[gpd.settingentrylist[0x63e83fff].data.length];
the dictionary not read only.
you writing bytes not dictionary data property inside value in dictionary.
if want override dictionary entry use -
foreach (keyvaluepair<int, settingentry> entry in settingentrylist) { var val = new settingsentry() { data = new datatype() }; pio.writebytes(val.data); entry.value = val; }
Comments
Post a Comment