p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning C# 6.0 Programming with Visual Studio 2015 (http://p2p.wrox.com/forumdisplay.php?f=798)
-   -   Chapter03 (http://p2p.wrox.com/showthread.php?t=98498)

BraneTronics January 28th, 2016 01:40 AM

Chapter03
 
After reading the third chapter, I feel like a cherry dipped in molten chocolate. I mean it might take some time to soak up all the information, but the authors gave it all. Thanks guys.

Cruisin... through.

workNhard February 13th, 2016 03:02 PM

Errata - code error on page 155
 
I didn't see the errata posting area for this book so I thought I would post it here.

The code on p. 155 ...

Code:

int i = 1;
do
{
  WriteLine("{0}", i++);
} while (i <= 10);

should be ....

Code:

int i = 1;
 do
 {
    WriteLine($"{i}", i++);
} while (i < 10);


BraneTronics February 14th, 2016 07:17 PM

No problem with the code!
 
First of all the code that you mentioned is in page 67 of my printed version of the book. Weird??? I don't see any problem with the code you mentioned either. The authors are trying to explain how the do...while loop works. The code in the book prints numbers 1 to 10 like it is supposed to.

If you are confused by the use of "{0}", i++ instead of $"{i}",i++ then both of these are valid C# code. Use of $"{i}",i++ being the latest C# 6.0 feature.

Try copying the code within -------- in visual studio and try it out.
-------------------------------------------------------------------------------
using System;

namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
int i = 1;
do
{
Console.WriteLine("{0}",i++);
} while(i <= 10);

Console.ReadKey();
}
}
}
----------------------------------------------------------------------------------
// Prints out
1
2
3
4
5
6
7
8
9
10

Hope this helps you understand how do...while loop works! [:)]

FittyFrank October 8th, 2016 12:03 AM

Ch. 3 Exercises
 
Hi all, I think the answer in the appendix to exercise 3.5 is incorrect.
Question:
By considering operator precedence, list the steps involved in the computation of the following expression:
resultVar += var1 * var2 + var3 % var4 / var5;

The precedence shown using parentheses in Appendix A is:
resultVar += (((var1 * var2) + var3) % (var4 / var5));

I believe the answer should be:
resultVar + ((var1 * var 2) + ((var3 % var4) / var5))

To me it seems as though the answer in the appendix gives preference to an addition operation over the % operation which is incorrect. It's late at night so I might just be sleepy, but feel free to take a look.


All times are GMT -4. The time now is 01:51 PM.

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