SpankySpanky
Programmer
I am using the TCPClient class in a project, and it has a protected property 'Client' which I would like to access to get properties of the underlying socket. As I understand it, a protected property can only be accessed from within the base class and derived classes, therefore I cannot access it as a normal property.
I tried making another SpecialTCPClient class which inherits TCPClient with the intention of exposing the protected property publicly as a readonly property. But when I receive a TCPClient object from the TCPListener and try to store it into my SpecialTCPClient variable, I get an error saying the cast is invalid. I thought this would work because it was derived from the TCPClient.
What am I doing wrong and how do I access the protected property if not this way? Why would it have been made protected in the first place?
Thanks for any insight.
I tried making another SpecialTCPClient class which inherits TCPClient with the intention of exposing the protected property publicly as a readonly property. But when I receive a TCPClient object from the TCPListener and try to store it into my SpecialTCPClient variable, I get an error saying the cast is invalid. I thought this would work because it was derived from the TCPClient.
What am I doing wrong and how do I access the protected property if not this way? Why would it have been made protected in the first place?
Thanks for any insight.