简体   繁体   English

我如何设置初始化 var c#?

[英]How can i set initialize var c#?

I'm new in c# and have this var:我是 C# 新手,有这个 var:

var updates = await Bot.GetUpdatesAsync(offset);


but now want updates define other scope and use it with this shape:但现在想要更新定义其他范围并将其与此形状一起使用:

updates = await Bot.GetUpdatesAsync(offset);


try define with this code:尝试使用此代码定义:

var updates =(string) null;


but in this line c# compiler get this error:但在这一行c#编译器得到这个错误:

    updates = await Bot.GetUpdatesAsync(offset);
(awaitable)Task<Update[]> TelegramBotClient.GetUpdatesAsync([int offset=0],[int limit=100],[int timeout=0],[CancellationToken cancellationToken=default(CancellationToken)
use this method recieve incoming updates using long polling.
Usage:
Update[] x=await GetUpdateAsync(...);
Can not implicitly convert type 'Telegram.Bot.Types.Update[]' to 'string'


How can i solve this code ?thanks:我该如何解决此代码?谢谢:

var updates =(string) null;

Obviously, return type of your method is not a string , but Telegram.Bot.Types.Update[] .显然,您的方法的返回类型不是string ,而是Telegram.Bot.Types.Update[]

So you can change the code to所以你可以将代码更改为

Telegram.Bot.Types.Update[] updates;
// the rest of code
updates = await Bot.GetUpdatesAsync(offset);

Replace var updates =(string) null;替换var updates =(string) null; with var updates =(Telegram.Bot.Types.Update[]) null;var updates =(Telegram.Bot.Types.Update[]) null;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM