我正在尝试使用Immediate WindowVisual Studio 2017将值写入文件。
我有一个名为 的变量_myItems,其类型为Dictionary<int, Dictionary<int, List<int>>>。
我确实遇到了breakpoint这个变量在范围内的地方。我可以跑
?_myItems
Run Code Online (Sandbox Code Playgroud)
在窗口中,我会得到一个列表,如:
Count = 9
[0]: {[536], System.Collections.Generic.Dictionary`2[System.Int32,System.Collections.Generic.List`1[System.Int32]]]}
[1]... omitted for clearance
... omitted for clearance
... omitted for clearance
[8]... omitted for clearance
Run Code Online (Sandbox Code Playgroud)
为了确保我可以在即时窗口中写入文件,我运行了:
File.WriteAllText("test.txt", "testing purposes");
Run Code Online (Sandbox Code Playgroud)
哪个确实写入了文件,因此我确定我可以从那里写入文件。
然后我尝试了以下方法:
?(foreach (KeyValuePair<int, Dictionary<int, List<int>>> pair in _myItems) { foreach (KeyValuePair<int, List<int>> valuePair in pair.Value) { foreach (int numberToWrite in valuePair.Value) { File.AppendAllText("test.txt",numberToWrite.ToString()); } }})
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
错误 CS1525:无效的表达式术语“foreach”
通过四处搜索,我遇到了这个问题,但接受的答案仅表明您可以做到。
如何foreach在立即窗口中运行此循环以将值写入文件。 …
作为开发DB,我正在使用MySQL,而对于测试我正在使用H2数据库.以下脚本在MySQL中运行良好,但在H2上失败.
UPDATE `table_a`
JOIN `table_b` ON `table_a`.id=`table_b`.a_id
SET `table_a`.b_id=`table_b`.id
Run Code Online (Sandbox Code Playgroud)
在互联网上我发现h2不支持UPDATE子句JOIN.也许有一种方法可以在没有JOIN子句的情况下重写这个脚本?
顺便说一下,我正在使用liquibase.也许我可以UPDATE用它的xml语言编写子句?
我尝试了以下脚本
UPDATE table_a, table_b
SET table_a.b_id = table_b.id
WHERE table_a.id = table_b.a_id
Run Code Online (Sandbox Code Playgroud)
但我仍然遇到错误.似乎,H2不支持在一个查询中更新多个表.如何在两个不同的查询中重写此查询以收集ID并插入它们?
在C#中,我正在调用一个公共API,其API限制为每秒10次调用.API有多种方法,不同的用户可以一次调用不同的方法,因此可能会出现"速率限制达到"异常.
我有以下类结构:
public class MyServiceManager
{
public int Method1()
{
}
public void Method2()
{
}
public string Method3()
{
}
}
Run Code Online (Sandbox Code Playgroud)
多个用户可以一次调用不同的方法,如何维护静态调用队列或任务,以便我可以监视所有请求并在一秒钟内只接受10个请求
斜杠命令已与交互框架一起添加到Discord.Net中。
通过查看文档,我发现我们可以在继承SlashCommandAttribute自InteractionModuleBase. 更多信息可以在这里找到。
请注意,我已经让这个机器人运行了一年多,所以它完全可以使用基本命令,并且我现在正在尝试更新它以使用斜杠命令。
我尝试过的是以下步骤:
在我的主要方法中,我监听了客户端就绪事件:
_client.Ready += _client_Ready;
Run Code Online (Sandbox Code Playgroud)
在_client_Ready函数中,您可以找到以下代码:
private async Task _client_Ready()
{
_interactionService = new InteractionService(_client);
await _interactionService.AddModulesAsync(Assembly.GetEntryAssembly(), _serviceProvider);
await _interactionService.RegisterCommandsToGuildAsync(_guildId);
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个继承自 InteractionModuleBase 的模块,如下所示:
public class TestingSlashCommandModule : InteractionModuleBase<SocketInteractionContext>
{
[SlashCommand("test-slash", "Echo an input")]
public async Task Echo(string input)
{
await RespondAsync(input);
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行机器人并访问我的不和谐服务器时,我可以看到已注册的斜杠命令:
但是,当我尝试使用它时,我在 Discord 上收到错误消息,指出应用程序没有响应,并且函数内的断点Echo根本没有被命中。
我不确定这是否是斜杠命令的用途,因为显然还有另一种方法可以做到这一点,但它看起来不像具有属性的模块那么干净。
有没有人能够在模块中使用斜杠命令SlashCommandAttribute,如何使用?
在 BigQuery,标准 SQL 中,如何在多个表上使用 _TABLE_SUFFIX ?见示例:
select *
from `table1.*` t1
left join `table2.*` t2 on t1.lel=t2.lel
where _TABLE_SUFFIX between '2017-01-01' and '2017-01-02' <--- this can't be used
Run Code Online (Sandbox Code Playgroud)
我是否必须首先创建一个 table2 的子查询,并将 table_suffix 应用于它?
我一直在互联网上搜索,但没有找到答案。你想告诉我,如何解码base64为Image折线图吗?我一直在尝试先从数组转换base64为Byte数组,然后从Byte数组转换为Image.
Private Function convertbytetoimage(ByVal BA As Byte())
Dim ms As MemoryStream = New MemoryStream(BA)
image = Image.FromStream(ms) 'I always get wrong in this line.
Return image
End Function
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 转换IST为UTC纪元Java
但不是从 中减去 5.30 小时IST,而是在 中添加 5.30IST
public static long convertDateToEpochFormat(String date) {
Date convertedDate = null;
try {
LOGGER.info(date);
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
LOGGER.info(date);
convertedDate = formatter.parse(date);
LOGGER.info(convertedDate);
} catch (ParseException e) {
e.printStackTrace();
}
return convertedDate.getTime() / 1000L;
}
Run Code Online (Sandbox Code Playgroud)
我获得的日志语句是:
2017-01-01 00:00:00
2017-01-01 00:00:00
Sun Jan 01 05:30:00 IST 2017
Run Code Online (Sandbox Code Playgroud)
由于 UTC 转换,理想情况下应为 12 月 31 日 18:30:00。
谁能告诉我怎么了?