Chapter 3 – Controlling the Flow, Converting Types, and Handling Exceptions

  1. What happens when you divide an int value by 0?

    A DivideByZeroException is thrown when dividing an integer or decimal.

  2. What happens when you divide a double value by 0?

    The double contains a special value of Infinity. Instances of floating-point numbers can have special values: NaN (not a number), PositiveInfinity, and NegativeInfinity.

  3. What happens when you overflow an int value that is set to a value beyond its range?

    It will loop unless you wrap the statement in a checked block in which case an OverflowException will be thrown.

  4. What is the difference between x = y++; and x = ++y;?

    In x = y++;, y will be assigned to x and then y will be incremented, and in x = ++y;, y will ...

Get C# 6 and .NET Core 1.0: Modern Cross-Platform Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.