Click here to Skip to main content
15,913,090 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to implement Pin
Colin Angus Mackay30-Jun-04 8:56
Colin Angus Mackay30-Jun-04 8:56 
GeneralRe: How to implement Pin
John L. DeVito30-Jun-04 13:27
professionalJohn L. DeVito30-Jun-04 13:27 
AnswerRe: How to implement Pin
Werdna30-Jun-04 5:46
Werdna30-Jun-04 5:46 
GeneralRe: How to implement Pin
Werdna30-Jun-04 5:47
Werdna30-Jun-04 5:47 
GeneralCollection class with different class members Pin
pxp29-Jun-04 21:31
pxp29-Jun-04 21:31 
GeneralRe: Collection class with different class members Pin
Rakker7129-Jun-04 23:07
Rakker7129-Jun-04 23:07 
GeneralRe: Collection class with different class members Pin
pxp30-Jun-04 5:05
pxp30-Jun-04 5:05 
GeneralRe: Collection class with different class members Pin
Heath Stewart30-Jun-04 5:56
protectorHeath Stewart30-Jun-04 5:56 
This is one thing that object-oriented programming solves. Define an abstract base class with all the properties and methods that are shared by every derivative class. Some of these properties may even be abstract themselves, declaring that derivative class must override them (perhaps to provide a friendly name of the object, rather than just returning the class name).

A simple hierarchy of classes I see from your list is like so:
abstract SchoolObject
+abstract Person
|+Student
|+Teacher
+abstract Item
|+Table
|+Chair
|+Classroom
|+Staircase
So the abstract SchoolObject would define the properties you need for everything. Your SchoolCollection accepts types of SchoolObjects, which can be an instance of any derivative class. As you're enumerating your collection, you can access the shared properties of SchoolObject, which - if virtual - the derivative classes can override to return different results.

This is really a core concept of object-oriented programming. If you're new to object-oriented programming or programming in general, I recommend you pick up a good book or two on object-oriented programming with .NET, such as Learn to Program with C#[^] (top-rating from a quick Amazon.com search). Object-oriented programming is also taught in most college curriculums, and can be picked pretty easily by reading through the documentation and looking at examples (CodeProject has thousands of examples).

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Collection class with different class members Pin
pxp30-Jun-04 7:32
pxp30-Jun-04 7:32 
GeneralRe: Collection class with different class members Pin
mav.northwind30-Jun-04 8:31
mav.northwind30-Jun-04 8:31 
GeneralRe: Collection class with different class members Pin
pxp30-Jun-04 23:41
pxp30-Jun-04 23:41 
GeneralRe: Collection class with different class members Pin
mav.northwind1-Jul-04 0:29
mav.northwind1-Jul-04 0:29 
GeneralRe: Collection class with different class members Pin
pxp1-Jul-04 3:28
pxp1-Jul-04 3:28 
GeneralRe: Collection class with different class members Pin
Heath Stewart30-Jun-04 8:35
protectorHeath Stewart30-Jun-04 8:35 
GeneralRe: Collection class with different class members Pin
pxp30-Jun-04 22:47
pxp30-Jun-04 22:47 
GeneralRe: Collection class with different class members Pin
Heath Stewart1-Jul-04 3:54
protectorHeath Stewart1-Jul-04 3:54 
GeneralRe: Collection class with different class members Pin
pxp1-Jul-04 4:05
pxp1-Jul-04 4:05 
Generalvariable object names Pin
rturner00329-Jun-04 20:13
rturner00329-Jun-04 20:13 
GeneralRe: variable object names Pin
Colin Angus Mackay29-Jun-04 20:49
Colin Angus Mackay29-Jun-04 20:49 
GeneralRe: variable object names Pin
Nick Parker30-Jun-04 3:15
protectorNick Parker30-Jun-04 3:15 
GeneralCPU time consuming program Pin
Mikke_x29-Jun-04 19:45
Mikke_x29-Jun-04 19:45 
GeneralRe: CPU time consuming program Pin
Colin Angus Mackay29-Jun-04 20:42
Colin Angus Mackay29-Jun-04 20:42 
GeneralRe: CPU time consuming program Pin
Mikke_x30-Jun-04 6:16
Mikke_x30-Jun-04 6:16 
GeneralTreeview count parents Pin
saud_a_k29-Jun-04 19:40
saud_a_k29-Jun-04 19:40 
Generaloops.. I got it Pin
saud_a_k29-Jun-04 19:45
saud_a_k29-Jun-04 19:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.