Say I have the following class...
Class1
{
private ArrayList myList;
private Class1
{
// Here fill myList with a bunch of Foo objects.
}
public ArrayList GetList()
{
return myList;
}
}
Then say in some other class you have the following code...
Class1 myClass = new Class1();
Foo myFavoriteFoo = myClass.GetList()[0] As Foo;
Now, myFavoriteFoo is actually a reference to the Foo that exists in the arraylist in Class1. What will happen if something inside Class1 removes that specific Foo from the class or disposes of it? Will myFavoriteFoo immediately = null? I am guessing if I tried to access Foo.SomeMethod() I would just get an exception like "Object reference not set to an instance of an object"...