Getting derived object from the base object
I extended the System.Net.Sockets.TcpClient class and I cannot figure out how to get an instance of my derived class when given an instance of the base TcpClient class.
For example, the TcpListner.AcceptTcpClient() method returns a TcpClient object. I would like to take that and get an instance of my derived class.
I tried to just cast it, but I get an invalid cast error - which I expected since the base object wasn't boxed from the derived object.
I tried to just assign the base object in the constructor of the derived class:
new MyTcpClient(TcpClient client) {
base = client;
}
but it wouldn't compile - "Use of keyword base is not valid in this context".
Can something like this even be done?