Closed FQanbari closed 1 year ago
You have not shown the code that caused your original exception but you probably entered the wrong code. The correct code is shown in the book:
[CallerArgumentExpression(nameof(condition))] string expression = "")
as shown in the following screenshot from the book:
thank you for your response, I updated my visual studio and disappeared this error.
Chapter: 4 Page Number: 182 Section Title: Logging information about your source code Step Number: Example of this section Problem to fix: The name 'condition' does not exist in the current context Suggested solution: using System.Diagnostics; // Trace using System.Runtime.CompilerServices; // [Caller...] attributes partial class Program { static void LogSourceDetails( bool condition, [CallerMemberName] string member = "", [CallerFilePath] string filepath = "", [CallerLineNumber] int line = 0, [CallerArgumentExpression("condition")] string expression = "") { Trace.WriteLine(string.Format( "[{0}]\n {1} on line {2}. Expression: {3}", filepath, member, line, expression)); } }