Programming C# 8.0 by Ian Griffiths

Programming C# 8.0 by Ian Griffiths

Author:Ian Griffiths [Ian Griffiths]
Language: eng
Format: epub
Publisher: O'Reilly Media, Inc.
Published: 2019-11-24T16:00:00+00:00


Example 2-20. Errors: some expressions that don’t work as statements

Console.ReadKey().KeyChar + "!"; Math.Sqrt(4) + 1;

Earlier I said that one kind of expression we’re allowed to use as a statement is an assignment. It’s not obvious that assignments should be expressions, but they are, and they do produce a value: the result of an assignment expression is the value being assigned into the variable. This means it’s legal to write code like that in Example 2-21. The second line here uses an assignment expression as an argument for a method invocation, which prints out the value of that expression. The first two WriteLine calls both display 123.



Loading...
Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.