Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2008, 01:27 AM
Registered User
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default List having properties of two different class.

HI . i want to create a list tht has properties of two different class.
suppose i have to class named Cats and Dogs then i want to create a list named PetAnimals which has properties of both Cats and Dogs class.Is that possible and if yes then how and if no then why??
 
Old April 3rd, 2008, 03:14 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

When you say 'properties' do you just mean you want to be able to add both Cats and Dogs to an array?

To do this you must ensure that the array will take objects that are a common parent of both the Cat and Dog class. So either these classes must inherit from a common base class (such as 'Animal') or you will have to use the Object class, which is the base class of all classes.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
get tagged properties of class using reflection Baby_programmer C# 2005 1 November 26th, 2007 05:54 AM
xml and class properties sushma.varala XML 0 July 14th, 2006 07:59 AM
xml or class properties sushma.varala Classic ASP Components 0 July 14th, 2006 07:52 AM
Adding to a class library using the List..Add BigJay86 C# 2 June 23rd, 2006 04:08 PM
Pass contents of drop down list to helper class snejsnej ASP.NET 1.0 and 1.1 Basics 0 April 12th, 2006 04:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.