gpt4 book ai didi

C# Multiline 多双引号字符串

转载 作者:行者123 更新时间:2023-12-04 07:30:58 26 4
gpt4 key购买 nike

我需要制作这段文字:

{
"method": "api.notifications.add",
"params": {
"name": "sequence.state.changed",
"options": {
"include_print_record": true,
"include_layout": true
}
},
"id": 0,
"jsonrpc": "2.0"
}

像这样用 C# 转换成一个字符串:


input = @"{
"method": "api.notifications.add",
"params": {
"name": "sequence.state.changed",
"options": {
"include_print_record": true,
"include_layout": true
}
},
"id": 0,
"jsonrpc": "2.0"
}";

它需要保留它的格式。我尝试了很多方法,包括在每个引号前放一个反斜杠,显然在第一个引号前放一个 @ 符号。

最佳答案

你可以用双引号("")来支持多行:

var input = @"{
""method"": ""api.notifications.add"",
""params"": {
""name"": ""sequence.state.changed"",
""options"": {
""include_print_record"": true,
""include_layout"": true
}
},
""id"": 0,
""jsonrpc"": ""2.0""
}";

dotnet fiddle 链接:https://dotnetfiddle.net/5sBzS1

关于C# Multiline 多双引号字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67929303/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com