【发布时间】:2019-05-08 13:36:07
【问题描述】:
我收到一个错误:CS1001 C# Identifier expected
static async Task<(bool, string)> TryGetHtml(string url)
{
if (string.IsNullOrEmpty(url))
{
return (false, null);
}
string html = await new HttpClient().GetStringAsync(url);
return (true, html);
}
附:使用(NET Framework 4.7.2)
【问题讨论】:
-
但是您使用的是哪个语言版本?项目属性 - 构建 - 高级(因为这是一种语言功能,而不是框架)
-
@Mihail 我检查了你的代码。它工作正常
-
c# 6.0 dotnetfiddle.net/kAVGgH
-
在 c#6 编译器中使用 c#7 功能无法正常工作docs.microsoft.com/en-us/dotnet/csharp/whats-new/…
-
Alexei Levenkov 谢谢!
标签: c# c#-6.0 .net-4.7.2