.net - adding new value to List overwrite previous value -
i'm trying add list. if move declaration loop works fine slow, if don't, add method overwrite previous values. what should do? dim _obj new classdal.site.salespoint dim _r = _obj.getcities dim temp new classdal.site.salespoint dim mylist new list(of classdal.site.salespoint) each row in _r temp.fullcode = convert.tostring(row.item(0)) temp.citycode = convert.tostring(row.item(1)) temp.karm = convert.toint32(row.item(2)) temp.name = convert.tostring(row.item(3)) mylist.add(temp) temp = new classdal.site.salespoint next return mylist you have declare varible inside loop reference type, otherwise in next loop modifying reference last item created. you try doing this, don't think quicker: for each row in _r mylist.add(new classdal.site.salespoint { .fullcode = convert.tostring(row.item(0)) .citycode = convert.tostring(row.item(1)) .karm = convert.toint3...