如何设置初始化var c#?

时间:2017-02-10 07:29:48

标签: c#

我是c#的新手,并且有这个var:

var updates = await Bot.GetUpdatesAsync(offset);


但现在想要更新定义其他范围并使用此形状:

updates = await Bot.GetUpdatesAsync(offset);


尝试使用此代码定义:

var updates =(string) null;


但在这行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'


我该如何解决这个问题?谢谢:

var updates =(string) null;

2 个答案:

答案 0 :(得分:0)

显然,您的方法的返回类型不是string,而是Telegram.Bot.Types.Update[]

因此您可以将代码更改为

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

答案 1 :(得分:0)

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