Z
zydjohn
Guest
Hello:
I found some RestSharp Code, it was written in .NET 4.5 and it seems working on a web page hosts the program. Now I am using .NET 4.7.1 with C# 7.2, I am using Visual Studio 2017, but the code is not compiled. The following is the code:
namespace ConsoleApplication3
{
using System;
using System.Threading;
using RestSharp;
public class Program
{
public static async void Main()
{
var client = new RestClient();
var request = new RestRequest("Google");
var cancellationTokenSource = new CancellationTokenSource();
var restResponse = await client.ExecuteTaskAsync(request, cancellationTokenSource.Token);
Console.WriteLine(restResponse.Content.Length);
}
}
}
The compiler error:
Severity Code Description Project File Line Suppression State
Error CS5001 Program does not contain a static 'Main' method suitable for an entry point ConsoleApplication3
But for its original web hosting page: C# Online Compiler | .NET Fiddle
It seems it is working. I want to know how to port it to .NET Framework 4.7.1 or 4.7.2
Its syntax seem to be a little different from what I see most of other C# programs.
Thanks,
PS: I used nuget to install RestSharp:
PM> Install-Package RestSharp -Version 106.3.1
Continue reading...
I found some RestSharp Code, it was written in .NET 4.5 and it seems working on a web page hosts the program. Now I am using .NET 4.7.1 with C# 7.2, I am using Visual Studio 2017, but the code is not compiled. The following is the code:
namespace ConsoleApplication3
{
using System;
using System.Threading;
using RestSharp;
public class Program
{
public static async void Main()
{
var client = new RestClient();
var request = new RestRequest("Google");
var cancellationTokenSource = new CancellationTokenSource();
var restResponse = await client.ExecuteTaskAsync(request, cancellationTokenSource.Token);
Console.WriteLine(restResponse.Content.Length);
}
}
}
The compiler error:
Severity Code Description Project File Line Suppression State
Error CS5001 Program does not contain a static 'Main' method suitable for an entry point ConsoleApplication3
But for its original web hosting page: C# Online Compiler | .NET Fiddle
It seems it is working. I want to know how to port it to .NET Framework 4.7.1 or 4.7.2
Its syntax seem to be a little different from what I see most of other C# programs.
Thanks,
PS: I used nuget to install RestSharp:
PM> Install-Package RestSharp -Version 106.3.1
Continue reading...