c# - How do I delete or reinitialize a 'new' variable? -
before report me asking commonly-asked question, hear me out.
i writing program read datalogger using c# , windows forms. each of channels can mean different things, such lift, drag, , pressure. plan make these channels configurable. here how such channel initialized:
private channel lift_channel = new channel(1);
this initializes lift_channel channel object references channel 1 on logger.
however, constructor method channel(int) method can use set channel. if want lift_channel point channel 2, this.
delete lift_channel; lift_channel = new channel(2);
i feel if can't delete lift_channel recreate it, have memory leak errors because channel(1) data floating around.
any ideas?
nope, nothing delete. after re-assign it, lift_channel no longer point old memory address, , memory cleaned up.
Comments
Post a Comment