Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing mmUser
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01013572
Message ID:
01014684
Views:
21
>Do you really have to create baseclass objects and then cast them to the child classes every time you want to access members of the child class? That seems like a lot of work to have to do just to access members of child classes. I would think that it is common to add functionality to classes when you subclass them and then want to use that functionality.
>
>Do you also have to do this cast to call new methods on child objects?
>
>Matthew J. Price

Matther,

I don't use C# so there will be others that can answer this better than I, but in your original post, you said you did this:
public override mmUser CreateUserObject()
{
	return new JdaUser();
}
and had problems with it. Well, in your override, you could probably do this instead:
public override JdaUser CreateUserObject()
{
	return new JdaUser();
}
Now, you can just use your user object with the knowledge of your new properties and methods. And the framework should still work fine since JdaUser is inherited from mmUser and the framework is only looking for properties and methods of mmUser and higher classes. I think (not 100% sure) you can always pass classes to methods expecting classes higher up the hierarchy implicitly. Meaning a method expecting mmUser could receive a JdaUser. It wouldn't be able to access any of the new properties and methods added to the JdaUser class, but would be able to access everything that the mmUser definition knew about.

I'm sure someone will correct me if I'm wrong here.

HTH,
Chad
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Reply
Map
View

Click here to load this message in the networking platform