Home All Groups Group Topic Archive Search About
Author
11 Aug 2006 10:08 AM
JFieseler
Hi all,

in a huge project i have the following problem.

I create an object which contains many public members (i know that this is
not correct, but it is a single use migration program). The members will be
filled from database tables. In the fill method i see in debug mode the
correct values. At the source where i create the object the DateTime members
of the object are not present (error: cannot obtain value). An statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, in this method is
the correct DateTime value present.
This all happens only for the DateTime members. Int32, String, .. are not
affected.

Who can help?

Josef Fieseler

Author
11 Aug 2006 10:20 AM
Morten Wennevik
Hi Josef,

Try to avoid multi-posting, please.  Stick to a single news group and po=
st  =

in others if noone replies within reasonable time (24 hours).

See my reply in the General group.


On Fri, 11 Aug 2006 12:08:01 +0200, JFieseler  =

<JFiese***@discussions.microsoft.com> wrote:

Show quote
> Hi all,
>
> in a huge project i have the following problem.
>
> I create an object which contains many public members (i know that thi=
s  =

> is
> not correct, but it is a single use migration program). The members wi=
ll  =

> be
> filled from database tables. In the fill method i see in debug mode th=
e
> correct values. At the source where i create the object the DateTime  =

> members
> of the object are not present (error: cannot obtain value). An stateme=
nt  =

> like
> this
> DateTime dat =3D object.startDate delivers 01/01/01.
> If the object reference will be pass to a other method, in this method=
is
> the correct DateTime value present.
> This all happens only for the DateTime members. Int32, String, .. are =
not
> affected.
>
> Who can help?
>
> Josef Fieseler



-- =

Happy Coding!
Morten Wennevik [C# MVP]
Author
13 Aug 2006 8:25 AM
Tigger
DateTime is a value type which means it cannot be null.

It defaults to 1/1/1 so you should treat this as its null equivalent.


Tony


JFieseler wrote:
Show quote
> Hi all,
>
> in a huge project i have the following problem.
>
> I create an object which contains many public members (i know that this is
> not correct, but it is a single use migration program). The members will be
> filled from database tables. In the fill method i see in debug mode the
> correct values. At the source where i create the object the DateTime members
> of the object are not present (error: cannot obtain value). An statement like
> this
> DateTime dat = object.startDate delivers 01/01/01.
> If the object reference will be pass to a other method, in this method is
> the correct DateTime value present.
> This all happens only for the DateTime members. Int32, String, .. are not
> affected.
>
> Who can help?
>
> Josef Fieseler

AddThis Social Bookmark Button