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

Aufrufer-Info-Attribute

Seit C# 5.0 können Sie optionale Parameter mit einem der drei Aufrufer-Info-Attribute versehen, die den Compiler anweisen, Daten, die aus dem Quellcode des Aufrufers entnommen werden, in den Standardwert für den Parameter aufzunehmen:

  • [CallerMemberName] wendet den Member-Namen des Aufrufers an.
  • [CallerFilePath] wendet den Pfad zur Quellcodedatei des Aufrufers an.
  • [CallerLineNumber] wendet die Zeilennummer in der Quellcodedatei des Aufrufers an.

Die Foo-Methode im folgenden Programm stellt alle drei vor:

using System;

using System.Runtime.CompilerServices;

class Program

{

static void Main() => Foo();

static void Foo (

[CallerMemberName] string memberName = null,

[CallerFilePath] string filePath = null,

[CallerLineNumber] ...

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