What class does an instance of IHost returned by HostBuilder.Build() belong to?

68 views Asked by At

I'm learning about Microsoft.Extensions.Hosting, and I've come across the HostBuilder.Build() method. I can see that it returns an instance of IHost interface ('an initialise IHost', according to learn.microsoft.com), but I don't know what class this instance object is a type of. Doesn't this object need to belong to a class that implements the IHost interface?

1

There are 1 answers

0
Guru Stron On

Doesn't this object need to belong to a class that implements the IHost interface?

Yes, HostBuilder.Build() returns an instance of class implementing the IHost interface, but the class itself can be an internal one (for example).

You can get the actual type name by calling GetType().FullName on the returned instance but in general you should not care about underlying implementation that much.