Click here to Skip to main content
15,917,481 members
Home / Discussions / C#
   

C#

 
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 
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 
Hi Mav,

Thanks, that did the trick !

I have the setup correct in general:

collection class with elements called obj which is an interface and all objects i store in the collection 'derive' from obj.

So, using class objects like:

public class objTeacher : obj

public class objStudent : obj


My problem (major error D'Oh! | :doh: ) was that i did not 'copy' the properties of a 'general' object to the object i need like your example:

if (o is Teacher)
{
    Teacher t = o as Teacher;
    string test = t.TeacherName;
    t.DoSomethingOnlyTeachersDo();
}


in my case i could not access the propertie TeacherName because it is an object/class specific property.

Casting it as a Teacher object did the trick !

How live can be sweet and simple sometimes Big Grin | :-D

So to understand the logic here, the Teacher is a derivate of the obj interface.

Is this the propper structure to enumerate and use different objects in 1 collection, or am i on a dangerous path here?

Me.
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 
GeneralOk One more question people Pin
saud_a_k29-Jun-04 19:57
saud_a_k29-Jun-04 19:57 
GeneralRe: Ok One more question people Pin
Heath Stewart30-Jun-04 6:02
protectorHeath Stewart30-Jun-04 6:02 
GeneralRe: Ok One more question people Pin
saud_a_k30-Jun-04 19:10
saud_a_k30-Jun-04 19:10 

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.