TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jshepler
NA
63
0
Getting derived object from the base object
Oct 5 2004 11:09 AM
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?
Reply
Answers (
7
)
How to generate HTML pages
Array of Checkboxes or Checkboxes in a PlaceHolder