Home > Net >  Destruction of doubt about the reference object
Destruction of doubt about the reference object

Time:10-07

Newbie questions

Have A temp class, generates the entity objects A, B, C, D...
There is a list Space of container,
Loading the generated ABCDRFG etc etc.

A new newA=temp object space [I],
Good luck, newA quotes, A

Question, I now want to use A deleted from the space of the container
The newA empty at the same time, but because I don't know how much I can't directly to delete A through Space, I also can't directly to operate A


This case, contact is A direct object is newA

How should I do through newA
1. From A space inside the container to destroy?

CodePudding user response:

?????
Space. Remove (newA);

CodePudding user response:

Space. Remove (newA)
NewA=null

Wait A moment will be A recovery

CodePudding user response:

Will automatically destroyed, you just need to manually removed, for the application type,=assignment is quoted, removed the newA, A space for [I] does not exist in the references,

CodePudding user response:

Destruction of objects and cannot be automatically removed from the space
So the approach is as follows:
NewA=null;//leave space [I] what is point to null
Cycle judgment space if null will remove
Int I=0;
For (I; i{
If (space [I]==null)
{
break;
}
}
Space. Remove (I);
  •  Tags:  
  • C#
  • Related