i've problem dictionary. it's said in title, i'm getting error everytime i'm trying delete same index 2 time in row.
id have dictionary of 60 entries, , remove entry 0, entry 1 should became entry 0, 2 entry 1,... should able delete entry 0 time, no ?
maybe i'm wrong, , can tell me how work ?
ps:i'm using remove() function.
foreach (var item in classboxlist) { uint classid = 0; bool contain = false; uint index = 0; uint = 0; foreach (var charclass in dbcstores.chrclasses.records) { if (charclass.name.string == item.name) classid = charclass.classid; } charbaseinfoentry charclassrace = new charbaseinfoentry() { raceid = (byte)raceid, classeid = (byte)classid }; foreach (var t in dbcstores.charbaseinfo.records) { if (t.classeid == classid && t.raceid == raceid) { contain = true; index = i; } i++; } if (contain) { if (item.selectedindex == 0) { //remove race/class entry messagebox.show(index+" -- "+ dbcstores.charbaseinfo.records.count.tostring()); dbcstores.charbaseinfo.removeentry(index); } } else { if (item.selectedindex == 1) { //add new race/class entry dbcstores.charbaseinfo.addentry(dbcstores.charbaseinfo.maxkey + 1, charclassrace); } } } public void removeentry(uint id) { if (!mrecords.containskey(id)) throw new exception("cette clé n'existe pas !"); isedited = true; mrecords.remove(id); }
you're not removing entry given index entry has given key
that, , in dictionary key unique trying remove 2 times in row same key nonsense (unless re-added somewhere else in meantime)
Comments
Post a Comment