Shaitan00 Posted December 29, 2003 Posted December 29, 2003 While running the code below I receive the following error �object reference not set to an instance of an object�, from my understanding this has to do with the initialization of objects, anyone able to see where I went wrong? [MAIN] m_Remote = new Remote(Count, iMachines); System.Data.DataSet oRecs = new System.Data.DataSet(); oRecs = m_Remote.Read; m_Remote.Setinfo(oRecs, iOIndex, iMIndex); << ERROR OCCURS HERE [CLASS] public class Remote { public object[,] m_obj; public Remote(int iO, int iM) { object[,] m_obj = new object[iO, iM]; } public System.Data.DataSet Read() { // Create Dataset oRecs dynamically return oRecs; } public void Setinfo (System.Data.DataSet rec, int oIndex, int mIndex) { m_obj[oIndex, mIndex] = rec; } } } Quote
Administrators PlausiblyDamp Posted December 29, 2003 Administrators Posted December 29, 2003 change public Remote(int iO, int iM) { object[,] m_obj = new object[iO, iM]; } to public Remote(int iO, int iM) { m_obj = new object[iO, iM]; } as you are re-declaring the array within the constructor at the moment. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.