Hello, I have the following code here:
class uno {
int x;
public uno(int i) {
x = i;
}
public void gen(int h) {
new uno(h);
}
}
class dos {
public static void Main() {
uno jj = new(0);
for (int i=1;i<=10;i++) {
jj.gen(i);
}
}
}
I read in the following book: memberfiles.freewebs.com/02/83/78118302/documents/McGraw.Hill.CSharp.4.0.The.Complete.Reference.Apr.2010.pdf
pages 134-135
that the gen(int i); method creates and destroys objects immediately.
Does this mean that in a loop whwnwver you create objects after each itertion, the objetc is created and detroyed immediately?
If yes, then how is that object destroyed(obviously not by the GC as It says that the object is destroyed IMMEDIATELY)?
Santosh KaranamPosted May 15, 2022, 4:44 PM
Sachin SinghPosted May 15, 2022, 3:27 PM
Muhammad Imran AnsariPosted May 15, 2022, 10:24 AM
Rajanikant HawaldarPosted May 15, 2022, 4:28 AM