Chapter 3 – Controlling the Flow, Converting Types, and Handling Exceptions
- What happens when you divide an
int
value by 0?A
DivideByZeroException
is thrown when dividing an integer or decimal. - What happens when you divide a
double
value by0
?The
double
contains a special value ofInfinity
. Instances of floating-point numbers can have special values:NaN
(not a number),PositiveInfinity
, andNegativeInfinity
. - 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 anOverflowException
will be thrown. - What is the difference between
x = y++;
andx = ++y;
?In
x = y++;
,y
will be assigned tox
and theny
will be incremented, and inx = ++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.