zoukankan      html  css  js  c++  java
  • Caller Information Attributes调用者信息特性

    这些信息有助于跟踪、调试和创建诊断工具。

    if the call site doesn't provide the argument, the compiler will use the current file, line number, or member name to fill in the argument instead of taking the normal default value. if the caller does supply an argument, the compiler will leave it alone.

    如果调用点不提供参数,编译器将使用当前文件、行号或成员名来填充实参,而不是使用正常的默认值。如果调用者确实提供了一个参数,编译器将不处理它。

    • CallerFilePathAttribute 包含调用者的源文件(编译时)的完整路径。
    • CallerLineNumberAttribute 调用方法在源文件中的行号。
    • CallerMemberNameAttribute 调用者的方法或属性名称。
            static void Main(string[] args)
            {
                ......
                voidTraceMessage();
            }
    
        static void TraceMessage(string msg = null, [CallerFilePath] string file = null, [CallerLineNumber] int line = 0, [CallerMemberName] string member = null)
        {
            Console.WriteLine(msg + " {0}: {1} - {2}", file, line, member);
        }
    
    ![](https://img2018.cnblogs.com/blog/1865358/201912/1865358-20191202180239828-1511843771.png)
  • 相关阅读:
    HDU 1249 三角形
    HDU 1799 循环多少次?
    UVA 12219-Common Subexpression Elimination
    POJ 2253-Frogger(最小生成树的最大权)
    OpenCV之参数不匹配问题
    vs2017-关于配置属性管理器的问题
    D
    圆桌会议
    F
    B
  • 原文地址:https://www.cnblogs.com/wesson2019-blog/p/11972394.html
Copyright © 2011-2022 走看看