T
trinitypete
Hi,
This post is just to check that I am not missing a point
somewhere.
I have a class say 'CLASSA' with a string member field
and associated property. I need an array of this class so
I execute the following code(C#)
CLASSA myclassarray = new CLASSA[5];
If I try to access the first elements memeber field
i.e. myclassarray.memberfield = "Hello";
I get an error saying object not set to instance of an
object. I thought this notation would create the complete
class array as the framework knows that each member of
the array is an instance of CLASSA.
If I initialise each element of the class array as
follows:
for ......
{
myclassarray = new CLASSA();
}
then I can access the member fields fine? Am I missing
something?
Thanks in advance, Pete.
This post is just to check that I am not missing a point
somewhere.
I have a class say 'CLASSA' with a string member field
and associated property. I need an array of this class so
I execute the following code(C#)
CLASSA myclassarray = new CLASSA[5];
If I try to access the first elements memeber field
i.e. myclassarray.memberfield = "Hello";
I get an error saying object not set to instance of an
object. I thought this notation would create the complete
class array as the framework knows that each member of
the array is an instance of CLASSA.
If I initialise each element of the class array as
follows:
for ......
{
myclassarray = new CLASSA();
}
then I can access the member fields fine? Am I missing
something?
Thanks in advance, Pete.