【问题标题】:Stored strings, Locale resource files, using C# 6 Interpolation?存储的字符串,区域设置资源文件,使用 C# 6 插值?
【发布时间】:2015-10-24 08:18:05
【问题描述】:

使用现有的String.Format,我可以将格式字符串放入数据库或资源文件中,而不是将其硬编码到我的应用程序中。插值有可能吗?

我猜不是,因为它似乎是编译器检查的东西。

【问题讨论】:

    标签: c# .net string-interpolation c#-6.0


    【解决方案1】:

    不,这是一个编译器:

    string result = $"{name}";
    

    编译成这样:

    string result = string.Format("{0}", name);
    

    而且你不能在这些存储的字符串上运行编译器。

    您可以存储带有编号参数的字符串,并明确使用string.Format

    【讨论】:

      猜你喜欢
      • 2016-01-17
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      • 2015-11-26
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多