Jump to content
Xtreme .Net Talk

Object reference not set to an instance of an object [C#]


Recommended Posts

Posted

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;

}

}

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...