gpt4 book ai didi

c# - 电报消息的OpenTl自动更新引发错误CS0079 C#

转载 作者:行者123 更新时间:2023-12-03 07:39:30 24 4
gpt4 key购买 nike

我最近尝试使用OpenTL快速入门页上的自动更新示例,仅使用以下基本示例

await clientApi.UpdatesService.AutoReceiveUpdates += update =>
{
// Handle updates
switch (update)
{
case TUpdates updates:
break;
case TUpdatesCombined updatesCombined:
break;
case TUpdateShort updateShort:
break;
case TUpdateShortChatMessage updateShortChatMessage:
break;
case TUpdateShortMessage updateShortMessage:
break;
case TUpdateShortSentMessage updateShortSentMessage:
break;
case TUpdatesTooLong updatesTooLong:
break;
}
};
它不会编译抛出此错误:

Error CS0079 The event 'IUpdatesService.AutoReceiveUpdates' can only appear to the left of += or -=


我将其放入异步Task函数中,但我认为这不是问题。我真的不知道如何使用这样的异步事件。
link to the example

最佳答案

您写的方式是错误的。它应该是

clientApi.UpdatesService.AutoReceiveUpdates += async update => 
{
// Handle updates
switch (update)
{

关于c# - 电报消息的OpenTl自动更新引发错误CS0079 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64806756/

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