A
Andreas Mueller
Hi All,
the following Situation is going through my mind:
class Xox
{
public Xox(){}
public object Foo(){ return null; }
}
class Class1
{
public delegate object Functor();
[STAThread]
static void Main(string[] args)
{
Functor f = new Functor(new Xox().Foo);
// do something with f later on, when
// nobody is referencing the Xox instance anymore
}
}
The newly created Xox object that is used to create the Delegate is not
referenced from anywhere. I would expect that the GC can collect it
anytime it sees fit. Is that true, or is the fact that a delegate is
referencing the Member function protecting it?
Thanks in advance,
Andy
the following Situation is going through my mind:
class Xox
{
public Xox(){}
public object Foo(){ return null; }
}
class Class1
{
public delegate object Functor();
[STAThread]
static void Main(string[] args)
{
Functor f = new Functor(new Xox().Foo);
// do something with f later on, when
// nobody is referencing the Xox instance anymore
}
}
The newly created Xox object that is used to create the Delegate is not
referenced from anywhere. I would expect that the GC can collect it
anytime it sees fit. Is that true, or is the fact that a delegate is
referencing the Member function protecting it?
Thanks in advance,
Andy