2つの異なるメソッド間で共有されるオブジェクトの配列が必要です。
私のウェブページのbutton1のonclickは、objectArrayに必要な値を設定するmethod1を呼び出します。method1が処理していたのと同じデータで同じobjectArrayにアクセスできるようにするには、button2のonclickメソッドが必要です。
using myWebReference;
{
public partial class _Default : System.Web.UI.Page
{
ObjectArray[] myObjects = new ObjectArray[100];
public void Page_Load(object sender, EventArgs e)
{
//I have nothing in here at the moment
}
public void method1(object sender, EventArgs e)
{
//myObjects[]'s values are calculated and assigned here.
}
public void method2(object sender, EventArgs e)
{
String key = myObjects[0].value;
//when I try to get data within myObjects here, myObjects does exist,
//but it is empty and I get a null reference error when I try to use its values.
}
}