鉴于我有一个存储在我的数据库中的元数据资源字符串将返回如下:
var pageTitle = "Shop the latest {category1} Designer {category2} {category3} at www.abc.com";
Run Code Online (Sandbox Code Playgroud)
我想替换{placeholders}变量values;
var category1 = "womenswear";
var category2 = "dresses";
var category3 = "cocktail dresses";
Run Code Online (Sandbox Code Playgroud)
我试过了,没有运气;
var newTitle = $"pageTitle, category1, category2, category3";
var newTitle = $(pageTitle, category1, category2, category3);
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用string.Replace()它有性能开销.有谁知道如何使用最新的C#字符串插值有效地完成这项工作?