Class problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this little test class:

public class Item
{

private int iID = 0;


public int tID
{
get { return iID; }
set { iID = value; }
}
}

when i declare it like this, everything works:
Item mTest = new Item();
mTest.tID = 0;

when i declare it like this:
Item[] mTest = new Item[3];
mTest[0].tID = 0;

i get this error:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Anyone know why?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top