ASP.NET 1.1, c# web application
I get an exception "Object reference not set to an instance of an object"
for the follwoing line:
myProductItem[0].ProductName = strProductName;
I have a class for product information "productitem":
public class productitem
{
public string ProductName;
public double ProductPrice;
public int ProductQuantity;
public int ProductDiscount;
public productitem()
{
//
// TODO: Add constructor logic here
//
this.ProductName = "";
this.ProductPrice = 0;
this.ProductQuantity = 0;
this.ProductDiscount = 0;
}
// I have declare an array of the productitem class as static:
public static productitem[] myProductItem;
// In my program I do the follwing
if (myProductItem == null)
{
myProductItem = new productitem[1000];
}
myProductItem[0].ProductName = strProductName; // here the exception occur
....
What's my fault?
Thanks in advance,
Michael