Visual Studio中 - 字符串插值快捷方式(没有安装VS扩展)

问题描述 投票:1回答:3

我开始写的消息,但不知道如果我需要它插。所以,我在消息的中间,并希望把一个$内插我的字符串。

如果一些快捷方式存在,那将是有益的。

像这样:

Log("Something happen here, at... (Oh God, I will need interpolate it..) {DateTime.Now}...");

是否有一个?

c# string visual-studio string-interpolation
3个回答
1
投票

随着ReSharper的你可以按alt+enter的第一个建议是“字符串插值”。

to string interpolation


1
投票

您可以添加以下命令到Visual指挥官,并分配一个快捷方式:Add the string interpolation character $ to the beginning of the current string


-1
投票

您可以在以下情况下与$使用它:

Log($"Something happen here, at... (Oh God, I will need interpolate it..) {DateTime.Now}...");

使用它之前,你需要安装Microsoft.Net.Compilers包的更多信息:https://blogs.msdn.microsoft.com/benjaminperkins/2017/03/23/how-to-enable-c-7-in-visual-studio-2017/

© www.soinside.com 2019 - 2024. All rights reserved.