Hi,
I'm trying to cast an object from its baseclass to my inherited class. I think it's called downcasting and from what i googled, this seems impossible in vb.net??
This is what i want to do :
I'm writing a tcp client / server application
for the client, i use TcpClient, but i inherited this class to K8055Client. An object of this class automatically start reading and creates events when commands arrive from the server...
I use this class K8055Client on both sides.
At the server side, at some point, i get an EndAcceptTcpClient function which returns me a TcpClient. How can i convert this TcpClient to K8055Client??
Again, at the server side, i want to place all my clients in a listbox. So i inherited K8055Client and made a class K8055ListViewItem.
So, at some point in my serverprogram where i want to add a client to my listbox, i get an object of type K8055Client that i want to convert to K8055ListViewItem
How would you program this situation, if you can't downcast?
I know i can add tcpclient as a member in K8055client
and add K8055Client as a member in K8055ClientListView but that does not solve my problem :
At some point i get a client who wants to disconnect : Type K8055Client. At that point i would like to do : ListBox.Items.Remove(client). This is only possible if K8055Client is a listviewitem and a tcpclient at the same time. This does not work when the K8055 client is a member of the class K8055ListViewItem...
I hope that what i wrote does make sense to anybody? How would i solve a situation like this?
I'm trying to cast an object from its baseclass to my inherited class. I think it's called downcasting and from what i googled, this seems impossible in vb.net??
This is what i want to do :
I'm writing a tcp client / server application
for the client, i use TcpClient, but i inherited this class to K8055Client. An object of this class automatically start reading and creates events when commands arrive from the server...
I use this class K8055Client on both sides.
At the server side, at some point, i get an EndAcceptTcpClient function which returns me a TcpClient. How can i convert this TcpClient to K8055Client??
Again, at the server side, i want to place all my clients in a listbox. So i inherited K8055Client and made a class K8055ListViewItem.
So, at some point in my serverprogram where i want to add a client to my listbox, i get an object of type K8055Client that i want to convert to K8055ListViewItem
How would you program this situation, if you can't downcast?
I know i can add tcpclient as a member in K8055client
and add K8055Client as a member in K8055ClientListView but that does not solve my problem :
At some point i get a client who wants to disconnect : Type K8055Client. At that point i would like to do : ListBox.Items.Remove(client). This is only possible if K8055Client is a listviewitem and a tcpclient at the same time. This does not work when the K8055 client is a member of the class K8055ListViewItem...
I hope that what i wrote does make sense to anybody? How would i solve a situation like this?