C# 8.0 Pocket Reference by Ben Albahari & Joseph Albahari

C# 8.0 Pocket Reference by Ben Albahari & Joseph Albahari

Author:Ben Albahari & Joseph Albahari [Ben Albahari]
Language: eng
Format: epub
Publisher: O'Reilly Media, Inc.
Published: 2019-11-18T16:00:00+00:00


Lambda Expressions

A lambda expression is an unnamed method written in place of a delegate instance. The compiler immediately converts the lambda expression to either of the following:

A delegate instance.

An expression tree, of type Expression<TDelegate>, representing the code inside the lambda expression in a traversable object model. This allows the lambda expression to be interpreted later at runtime (we describe the process in Chapter 8 of C# 8.0 in a Nutshell).

Given the following delegate type

delegate int Transformer (int i);

we could assign and invoke the lambda expression x => x * x as follows:

Transformer sqr = x => x * x; Console.WriteLine (sqr(3)); // 9



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.