Skip to Content
C# 7.0 – kurz & gut, 5th Edition
book

C# 7.0 – kurz & gut, 5th Edition

by Joseph Albahari, Ben Albahari
April 2018
Intermediate to advanced content levelIntermediate to advanced
238 pages
4h 32m
German
dpunkt
Content preview from C# 7.0 – kurz & gut, 5th Edition

Lambda-Ausdrücke

Ein Lambda-Ausdruck ist eine Methode ohne Namen, die anstelle einer Delegate-Instanz geschrieben wird. Der Compiler wandelt den Lambda-Ausdruck direkt um, und zwar

  • in eine Delegate-Instanz oder
  • in einen Expression Tree vom Typ Expression<TDelegate>, der den Code im Lambda-Ausdruck in einem traversierbaren Objektmodell repräsentiert. Damit können Lambda-Ausdrücke zur Laufzeit interpretiert werden.

Wenn wir den Delegate-Typ

delegate int Transformer (int i);

haben, können wir den Lambda-Ausdruck x => x * x wie folgt zuweisen und ausführen:

Transformer sqr = x => x * x;

Console.WriteLine (sqr(3)); // 9

image

Intern löst der Compiler ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 – kurz & gut, 6th Edition

C# 8.0 – kurz & gut, 6th Edition

Joseph Albahari, Ben Albahari
Reguläre Ausdrücke Kochbuch

Reguläre Ausdrücke Kochbuch

Jan Goyvaerts, Steven Levithan

Publisher Resources

ISBN: 9781492067740