Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 6 > BOOK: Beginning C# 6.0 Programming with Visual Studio 2015
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 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 June 21st, 2016, 08:06 PM
Registered User
Join Date: Jun 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow Console.WriteLine mysteriously becomes WriteLine

Sooo... I'm not sure how everyone else figured this out unless they went straight to the code download:

Somewhere around Chapter 4 the author starts using
instead of

I thought I knew the answer - just add
using System.Console;
to the top of my C# code file.

Well, that doesn't work.

So I downloaded the sample code for this book and opened it, and discovered that all of the source files have this near the top:
using static System.Console;
Still not sure where this came from, I went back and re-read chapter 3.

There, at the VERY END of chapter 3, in the very last paragraph hides a very IMPORTANT clue:
"when the using static System.Console namespace is added to the list of included namespaces, accessing the WriteLine() method no longer requires the preceding static class name"

If you're not carefully reading every word of this book, you'll miss this information. In my opinion the authors should have emphasized this.

To make it more confusing, the exercises in the book are not "complete". In other words, the instructions say to create a new console application (for example) and then they give you the code that goes inside static void Main.

What's not obvious in any exercise is that the Main method is just a portion of the complete code. ("Main" is inside of "class Program", which in turn is inside of "namespace".)

Yes, Visual Studio adds all of that for you. Fair enough. But what it does NOT automatically add is "using static System.Console;" and THAT is the important missing piece.

If you don't add this line at the top of your code, "WriteLine()" will not work.

By the way:
I understand and appreciate how the authors chose to print partial code blocks in the book. My point is, at least somewhere in the book, they should have made it REALLY clear to everyone how/why "Console.WriteLine()" can be replaced with "WriteLine()"

Other than that, I am really enjoying the book.
Old August 16th, 2016, 12:16 PM
Registered User
Join Date: Aug 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

At the very top of page 51, at the very end of chapter 3, it says:
"All code examples requiring the System.Console static class from this point forward include the using static System.Console keyword."

I agree that it was very easy to miss that. It would have been better if it had been called out as a NOTE
Old July 4th, 2017, 12:03 PM
Registered User
Join Date: Jul 2017
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Same Issue with System.Convert

I experienced the same problem with .Convert as is mentioned for .Console.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ex 19-4 Console.WriteLine question zavodney BOOK: Stephens' Visual Basic Programming 24-Hour Trainer 2 August 14th, 2011 10:39 PM
Ch3 Ex2 Console.WriteLine question thelafe BOOK: Beginning Visual C# 2010 2 June 11th, 2011 08:40 AM
writeline to an application Vinny_68 Pro Visual Basic 2005 0 April 16th, 2007 09:40 AM
Problem with First.cs output via Console.WriteLine patrick764 C# 1 November 7th, 2005 03:17 PM
Console.WriteLine ritag ADO.NET 2 February 9th, 2005 11:09 AM

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