目录
c#8 | .NET Framework 4.8、.NET Core 3.0、.NET Core 3.1 |
c#9 | .NET 5 |
c#10 | .NET 6 |
catch 子句中的 when
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static void Main()
{
Console.WriteLine(MakeRequest().Result);
}
public static async Task<string> MakeRequest()
{
var client = new HttpClient();
var streamTask = client.GetStringAsync("https://localHost:10000");
try
{
var responseText = await streamTask;
return resp