Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning C# 6.0 Programming with Visual Studio 2015
This is the forum to discuss the Wrox book Beginning C# 6.0 Programming with Visual Studio 2015 by Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid; ISBN: 978-1-119-09668-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 6.0 Programming with Visual Studio 2015 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 21st, 2017, 12:05 AM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2017
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 4 exercise 2

You have to add
using static System.Console;

and then you have to put Convert. in front of the ToDouble
So it looks like this, because otherwise it won't run the way they have it in the book: [code]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace Ch04Ex02
{
class Program
{
static void Main(string[] args)
{
string comparison;
WriteLine("Enter a number: ");
double var1 = Convert.ToDouble (ReadLine());
WriteLine("Enter another number: ");
double var2 = Convert.ToDouble(ReadLine());
if (var1 < var2) comparison = "less than";
else {
if (var1 == var2) comparison = "equal to";
else comparison = "greater than";
}
WriteLine($"The first number is {comparison} the second number.");
ReadKey();
}
Reply With Quote
  #2 (permalink)  
Old January 19th, 2018, 01:05 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Add this on the top of your code:

using static System.Convert;
Reply With Quote
Reply


Thread Tools
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
Chapter 1 exercise #7 Alan G BOOK: Python Projects 0 December 21st, 2015 10:08 PM
Chapter 4 Exercise 4.2 PLEASE HELP NewbySwaj BOOK: Beginning Visual C# 2012 1 November 25th, 2013 11:49 AM
Chapter 3: exercise 2. tobbeebbot BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 3 September 7th, 2012 12:09 AM
Chapter 4 exercise 4 earlmw BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 0 March 3rd, 2012 03:05 PM
Chapter 4 Exercise 4 Will BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 2 September 18th, 2009 12:08 PM



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


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