Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3
This is the forum to discuss the Wrox book Beginning C# 3.0 : An Introduction to Object Oriented Programming by Jack Purdum; ISBN: 9780470261293
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 13th, 2014, 09:41 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2014
Location: England
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch5 p130 DateTime

Hi. Sorry for harping on about the same bit of code as others have.
In my version of the dateTime code I am getting an error "DateTime" is a namespace but is being used like a 'type' on the 2 lines that mention DateTime (in the code for the UpdateTimeInfo method).

Code:
private void UpdateTimeInfo()
    {
        int days;
        DateTime myTime = new DateTime();
        myTime = DateTime.Now;
        DateTime newYears = new DateTime(myTime.Year, 12, 31);
I have now downloaded the code from the Wrox site but still get this error. I am using 2010 express.
What am I doing wrong please?
 
Old March 14th, 2014, 08:47 PM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

look at the namespace that this code resides in; is it DateTime? if it is then the reason you are getting the erorrs is because the complier does not know what DateTime you are trying use so it makes a guess and gives you an error. To fix fully qualify the the DateTime you are trying to instanciate.

Code:
private void UpdateTimeInfo()
    {
        int days;
        System.DateTime myTime = new System.DateTime();
        myTime = System.DateTime.Now;
        DateTime newYears = new System.DateTime(myTime.Year, 12, 31);
}
 
Old March 17th, 2014, 08:58 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2014
Location: England
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile DateTime

Thanks for that. I understand your reply now. However in the book, scope does not seem to be dealt with until Part III.
I naively thought that because the code includes a reference to "using System" that this would have satisfied any reference to DateTime--obviously not!


Thanks again
 
Old March 17th, 2014, 07:27 PM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

Had this code resided in a namespace that was Datetime it would have been sufficient but since it did you have to fully qualify any names that are in any of the name spaces.




Similar Threads
Thread Thread Starter Forum Replies Last Post
CH5 - Code for DateTime Tester Application? alwayssummer BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 4 December 16th, 2010 12:11 PM
3 days prior datetime from current datetime bsridharg XSLT 2 June 11th, 2010 11:26 PM
How do I compare a datetime to current datetime and find the one closest to it? Anders XSLT 17 March 15th, 2010 10:28 AM
CH5 ObjectDataSource nabeelalkaff BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 8th, 2007 01:19 PM
UTC DateTime to Local DateTime r_ganesh76 SQL Server 2000 1 April 4th, 2005 08:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.