- To call an API for data, we can use the built-in HttpClient that comes with the System.Net namespace.
using (HttpClient client = new HttpClient())
{
var response = await client.GetStringAsync("https://referbruv.com");
Console.WriteLine(response);
}
- HttpClient implements the IDisposable interface and so can be used under a using block. But it is one of those unmanaged resources which should not be released frequently and instead be reused as much as possible.