arrays and structures - help needed please

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

Guest

internal struct ConstantValue
{
internal DateTime EffectiveFrom;
internal DateTime EffectiveThrough;
internal DateTime DateValue;
internal double DoubleValue;
}

internal struct Constant
{
internal ConstantValue[] Value;
internal String Name;
}
From inside a function, when I try to do the following,
i = 0;

constant.Value.EffectiveThrough = new DateTime
(2004,1,1,0,0,0);
I am getting the exception, "object reference not set to
an instance of an object". Please give your valuable
suggestions. Thanks a lot.
 
You would need to initialize your Value variable.
Something like this... ie constant.Value = new ConstantValue[10];
HTH

internal struct ConstantValue
{
internal DateTime EffectiveFrom;
internal DateTime EffectiveThrough;
internal DateTime DateValue;
internal double DoubleValue;
}

internal struct Constant
{
internal ConstantValue[] Value;
internal String Name;
}
From inside a function, when I try to do the following,
i = 0;

constant.Value.EffectiveThrough = new DateTime
(2004,1,1,0,0,0);
I am getting the exception, "object reference not set to
an instance of an object". Please give your valuable
suggestions. Thanks a lot.
 
internal struct ConstantValue
{
internal DateTime EffectiveFrom;
internal DateTime EffectiveThrough;
internal DateTime DateValue;
internal double DoubleValue;
}

internal struct Constant
{
internal ConstantValue[] Value;
internal String Name;
}
From inside a function, when I try to do the following,
i = 0;

constant.Value.EffectiveThrough = new DateTime
(2004,1,1,0,0,0);
I am getting the exception, "object reference not set to
an instance of an object". Please give your valuable
suggestions. Thanks a lot.


You haven't shown anywhere where you've initialised the Value array, eg
a statement like

Value = new ConstantValue[50];

Until you do so, you won't have created an actual array.
 
Back
Top