Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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?
  #2 (permalink)  
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);
}
  #3 (permalink)  
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
  #4 (permalink)  
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.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.