c# - object crashing say it is NULL -
this question has answer here:
- what nullreferenceexception, , how fix it? 29 answers
i've created class
public partial class subrank { private system.datetime startdatefield; public system.datetime startdate { { return this.startdatefield; } set { this.startdatefield = value; } } } im trying create array of this...
subrank[] pastsubrank = new subrank[1]; pastsubrank[0].startdate = datetime.parse("2012-05-22"); but pastsubrank[0] crashing saying null....why this?
yes cause haven't instantiated class subrank before accessing it's property.
subrank[] pastsubrank = new subrank[1]; pastsubrank[0] = new subrank(); pastsubrank[0].startdate = datetime.parse("2012-05-22");
Comments
Post a Comment