473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

arrays and structures - help needed please

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[i].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.
Nov 16 '05 #1
2 1694
You would need to initialize your Value variable.
Something like this... ie constant.Value = new ConstantValue[10];
HTH

an*******@discussions.microsoft.com wrote:
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[i].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.


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
Nov 16 '05 #2
<an*******@discussions.microsoft.com> wrote:
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[i].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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Java script Dude | last post by:
Some programmers prefer to stay with native level data structures such as string arrays instead of using Object based data structures such as ArrayList. From and efficiency point of view. Are...
33
by: Peter Seaman | last post by:
I understand that structures are value types and arrays and classes are reference types. But what about arrays as members of structures i.e. as in C struct x { int n; int a; }
2
by: | last post by:
internal struct ConstantValue { internal DateTime EffectiveFrom; internal DateTime EffectiveThrough; internal DateTime DateValue; internal double DoubleValue; } internal struct Constant {
4
by: mom_newbie | last post by:
Hello all, I want to perform the following task: 1. Create an array 2. Fill it up (number of elements unknown in advance) 3. Iterate through it using For Each loop (cannot do this in the in...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
12
by: Anil Gupte | last post by:
How can I dimension an array like this: dim info(a as integer, b as string) so I can store somthing like {{"John", 10}{"Dan", 20}{"Jane", 30}} I want to be able to sort this array too, but I...
35
by: Andrew Fabbro | last post by:
I have a need to create an array that is larger than size_t - 1, which I believe is the largest guaranteed array. I though I'd found salvation in FAQ 6.14, but it appears I am not understanding...
127
by: sanjay.vasudevan | last post by:
Why are the following declarations invalid in C? int f(); int f(); It would be great if anyone could also explain the design decision for such a language restricton. Regards, Sanjay
19
by: John Whitworth | last post by:
Hi, Firstly, apologies if what I am asking seems really obvious. I'm a self-taught VB2008 (via VB4, VB6 and VB2003) user, and have always just picked up what I need to know, when I need to know...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.