473,386 Members | 1,883 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,386 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 1698
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.