Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.ServiceModel.ServiceHost implements IDisposable but Dispose is not public

Why is that?

This is not a question about the using keyword.

like image 981
Stig Avatar asked Mar 17 '11 11:03

Stig


1 Answers

System.ServiceModel.ServiceHost implements the IDisposable interface explicitly. This prevents that interface complicating the the ServiceHost class itself. It also avoids situations where more than one interface implemented by a class defines a method with the same signature.

The Dispose method can be accessed by casting the ServiceHost object to an IDisposable.

Also helpful Q/A around it.

like image 52
sheikhjabootie Avatar answered Sep 24 '22 03:09

sheikhjabootie