在Visual Studio 2017中构建ConsoleApp后无法运行 [重复]。

问题描述 投票:0回答:1

我是一个编程新手....我在Visual Studio 2017中用下面的代码编写了一个ConsoleApp....

using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace HttpClientStatus
{
    class Program
    {
        static async Task Main(string[] args)
        {
                var client = new HttpClient();
                var result = await client.GetAsync("http://webcode.me");
                Console.WriteLine(result.StatusCode);


        }
    }
}

Build运行成功,但执行exe文件后,屏幕上似乎没有任何东西显示出来。

控制台的输出应该是这样的。

$ dotnet run
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My html page</title>
</head>
<body>

    <p>
        Today is a beautiful day. We go swimming and fishing.
    </p>

    <p>
         Hello there. How are you?
    </p>

</body>
</html>

请帮助...

Regards...

c# html windows visual-studio console-application
1个回答
0
投票

Console.Read(); 此后 Console.WriteLine(result.StatusCode);如果你不这样做,代码将完全运行,但不会向你显示任何东西。

© www.soinside.com 2019 - 2024. All rights reserved.