P
.pd.
Hello,
I'm trying to setup a named-object list using objects of 3 different
types all derived from the same base class.
public class namedObjectList :
System.Collections.Specialized.NameObjectCollectionBase
{
public BaseType this[string name]
{
get { return BaseGet(name); }
}
public void Add(string key, BaseType obj)
{
BaseAdd(key, obj);
}
}
I then have my 3 derived types:
public class Derive1 : BaseType {...}
public class Derive2 : BaseType {...}
public class Derive3 : BaseType {...}
I can add instances of these 3 derived types with no problem but when I
do this:
string s = myNamedObjectList["whatever"].GetType().Name
I get back "BaseType" when what I really wanted was whichever one of the
derived types was added.
Should this work? How can I get what I want?
Thanks for any help,
..pd.
I'm trying to setup a named-object list using objects of 3 different
types all derived from the same base class.
public class namedObjectList :
System.Collections.Specialized.NameObjectCollectionBase
{
public BaseType this[string name]
{
get { return BaseGet(name); }
}
public void Add(string key, BaseType obj)
{
BaseAdd(key, obj);
}
}
I then have my 3 derived types:
public class Derive1 : BaseType {...}
public class Derive2 : BaseType {...}
public class Derive3 : BaseType {...}
I can add instances of these 3 derived types with no problem but when I
do this:
string s = myNamedObjectList["whatever"].GetType().Name
I get back "BaseType" when what I really wanted was whichever one of the
derived types was added.
Should this work? How can I get what I want?
Thanks for any help,
..pd.