Answer the question
In order to leave comments, you need to log in
The lifetime of an object if a reference to its field was passed to a static class?
Here is an example code:
static class A
{
static D d;
void static Func1()
{
B b = new B();
d = b.Func2();
}
void static Main()
{
Func1();
GC.Collect();
System.Threading.Thread.Sleep(10000);
//b is removed?
}
}
class B
{
public D d = new D();
public D Func2()
{
return d;
}
}
class D
{
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question