using System;
using System.Reflection;
using System.Collections;
class ListModifier{
public ListModifier()
{
ArrayList list = (ArrayList)AppDomain.CurrentDomain.GetData("Pets");
list.Add("turtle");
}
}
class MainClass{
public static void Main(){
AppDomain domain = AppDomain.CreateDomain("Test");
ArrayList list = new ArrayList();
list.Add("dog");
list.Add("cat");
list.Add("fish");
domain.SetData("Pets", list);
domain.CreateInstance("MainClass","Apress.VisualCSharpRecipes.Chapter03.ListModifier");
foreach (string s in (ArrayList)domain.GetData("Pets")) {
Console.WriteLine(s);
}
}
}
|