zoukankan      html  css  js  c++  java
  • C#中的@和$ 占位符

    c#中@的三种用法:

    1.忽略转移字符

    string str = "C:\windows\system32";

    string str = @"C:windowssystem32";

    2.字符串跨行

    string str = "SELECT * FROM Employee AS e"

      + "INNER JOIN Contact AS c"

      + "ON e.ContactID = c.ContactID"

      + "ORDER BY c.LastName";

    string str = @"SELECT * FROM Employee AS e

      INNER JOIN Contact AS c"

      ON e.ContactID = c.ContactID"

      ORDER BY c.LastName";

    3.将关键字作为标识符使用

    int @int = 1;

    c#中$的使用

    简化string.Format()写法

    string name = "上帝";

    int age = 0;

    string str = string.Format("my name is {0},I`m {1} years old",name,age);

    可简写为

    string str = $"my name is {name},I`m {age} years old";

    需要输出"时使用"

    需要输出{}时使用{{ }}

    string str = $"my "name" is {{{name}}},I`m {age} years old";

  • 相关阅读:
    python入门-数据类型
    jmeter进行简单性能测试
    Charles抓包工具
    jemter分布式部署及linux下分布式脚本执行
    Java-List
    重载
    static关键字
    pycharm问题
    charles安装使用及问题
    安装pipenv
  • 原文地址:https://www.cnblogs.com/1016391912pm/p/11486854.html
Copyright © 2011-2022 走看看