How do you initialise a class using the C#12 primary construtor syntax. I know how to do it using dependency injection but cant find any docs showing how to do it with a normal class.
here is what I want to change to the primary constructor syntax.
internal class AutoHttpClient : IAutoHttpClient
{
private readonly HttpClient httpClient;
public AutoHttpClient()
{
httpClient = new HttpClient();
}
}
im guessing that just doing the below will not work or will it?
internal class AutoHttpClient(HttpClient httpClient) : IAutoHttpClient
{
}
I have also looked onlint but all the examples aside of DI were using base types like int etc. Thanks for the help.
class AutoHttpClient(HttpClient httpClient): IAutoHttpClient { readonly HttpClient httpClient = httpClient; }