R
RMD
I need to be able to keep a list of object references, and null them out one
by one at a later point in time. I realize this can be dangerous, but I have
my reasons.
I can't figure out, however, how to keep what is essentially a reference to
a reference. I want to store my objects in an ArrayList, then loop through
the array list and null out the original reference I was given when I added
it to my Array List.
Below is some example code:
//Here is some example usage
object nullMe;
Nuller nuller = new Nuller();
nullMe = new object();
nuller.AddToNullList(ref nullMe);
nuller.NullItOut();
//Here is my "Nuller" class:
public class Nuller
{
private ArrayList m_NullList = new ArrayList();
public void AddToNullList(ref object nullMe)
{
m_NullList.Add(nullMe);
}
public unsafe void NullItOut()
{
for(int i = 0; i < m_NullList.Count; i++)
{
//I want this to null out the original reference... the "nullMe"
variable in the usage example code.
m_NullList = null;
}
}
}
How do I accomplish this?
RMD
by one at a later point in time. I realize this can be dangerous, but I have
my reasons.
I can't figure out, however, how to keep what is essentially a reference to
a reference. I want to store my objects in an ArrayList, then loop through
the array list and null out the original reference I was given when I added
it to my Array List.
Below is some example code:
//Here is some example usage
object nullMe;
Nuller nuller = new Nuller();
nullMe = new object();
nuller.AddToNullList(ref nullMe);
nuller.NullItOut();
//Here is my "Nuller" class:
public class Nuller
{
private ArrayList m_NullList = new ArrayList();
public void AddToNullList(ref object nullMe)
{
m_NullList.Add(nullMe);
}
public unsafe void NullItOut()
{
for(int i = 0; i < m_NullList.Count; i++)
{
//I want this to null out the original reference... the "nullMe"
variable in the usage example code.
m_NullList = null;
}
}
}
How do I accomplish this?
RMD