存储的字符串,Locale资源文件,使用C#6插值?

Jes*_*dll 8 .net c# string-interpolation c#-6.0

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

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

i3a*_*non 12

不,这是一个编译器的事情:

string result = $"{name}";
Run Code Online (Sandbox Code Playgroud)

编译成这样:

string result = string.Format("{0}", name);
Run Code Online (Sandbox Code Playgroud)

并且您无法在这些存储的字符串上运行编译器.

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