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:
01014744
Views:
19
Jim,

>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?

You do. With strong typing, when you specify a variable is of a particular type, you can only access the members of that class. So, for example, if you have a variable of the type mmUser, but instantiate a SUBCLASS of mmUser:
mmUser User = new JdaUser();
You can only access members of the mmUser class. This is strong typing.

If you want to access the members of the subclass, you must cast the object to that type. For example (notice I did the retrieval and cast in one line of code):
JdaUser User = (JdaUser)mmAppBase.Factory.CreateUserObject();
Console.WriteLine(User.InitVecField);
Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform