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)
  • 相关阅读:
    mysql主从延迟高的原因
    OpenStack云平台网络模式及其工作机制
    maps.reg
    dnion的remap.conf文件
    linux的tar命令
    traffic server文件目录
    records.config文件参数解释
    VNC配置
    KVM详情
    cache.config文件配置模板
  • 原文地址:https://www.cnblogs.com/wesson2019-blog/p/11972394.html
Copyright © 2011-2022 走看看