cannot create correct DateTime

  • Thread starter Thread starter Mark Broadbent
  • Start date Start date
M

Mark Broadbent

why does this code not work for me

DateTime dt = new DateTime(2000,10,1);


Looking in Locals a date of 1/1/1 is created??

According to the overloaded constructor DateTime(int year, int month, int
day) should work.

Br,

Mark.
 
That line of code works great for me. Create a separate project with

static void Main()
{
DateTime dt = new DateTime(2000,10,1);
Console.WriteLine(dt);
}

and see what comes out - lets just rule out your setup.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<#[email protected]>

why does this code not work for me

DateTime dt = new DateTime(2000,10,1);


Looking in Locals a date of 1/1/1 is created??

According to the overloaded constructor DateTime(int year, int month, int
day) should work.

Br,

Mark.



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004



[microsoft.public.dotnet.languages.csharp]
 
Hi Mark

Your code is correct. If you output the content of dt in a MessageBox, do you still get 1/1/1?
If so, I suspect you did not use the same code. Sometimes the debugger gets things mixed up.
 
Mark Broadbent said:
why does this code not work for me

DateTime dt = new DateTime(2000,10,1);


Looking in Locals a date of 1/1/1 is created??

According to the overloaded constructor DateTime(int year, int month, int
day) should work.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Its Official ...Im a plonker!

I was having trouble doing something with datetime so reverted to checking
values. After reading your replies I realised what the problem was with this
statement (you are all right -nothing).
What I did was set the breakpoint on this line and the Locals window was
just displaying pre-assignment value.
Setting the breakpoint on the next line does indeed display the assignment
value in the constructor.

Thx Richard, Morten, Jon.

Sorry guys -Im an idiot! :-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top