Because in the method signature, the endPoint parameter is declared as endPoint , not IPEndPoint ; there is no guarantee that the method will not set endPoint to another type of endPoint that will not be assigned to the IPEndPoint variable.
For example, suppose you have a FooEndPoint class that inherits from endPoint , and a Foo method that accepts the ref EndPoint :
public class FooEndPoint : EndPoint { ... } public void Foo(ref EndPoint endPoint) { ... endPoint = new FooEndPoint(); ... }
If you were able to pass IPEndPoint this method, then the FooEndPoint parameter to the endPoint parameter will fail at runtime because FooEndPoint not IPEndPoint
source share