Panteralow
New Member
I'm new to ASP.NET, C#, as well as OOP in general. I want to have an array of objects that is shared between two different methods.The onclick for button1 on my webpage calls method1, which populates the needed values for the objectArray. I need the onclick method for button2 to be able to access the same objectArray with the same data that method1 was working with.\[code\]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. }}\[/code\]As mentioned, I am just learning these languages and I am probably going about this the wrong way. But I'd appreciate any helpful advice, please. Thank you.