Hello!
Assume I have this inheritance see below.
I know that a much better alternative is to use generics but I just want to
know how things works.
According to the documentation in CollectionBase for member List it return
an IList.
In the class Int16Collection I check by using method Test what this List in
CollectionBase is actually refering to and
it's refering to Int16Collection .
So according to that and the documenation we should have this kind of
situation.
IList List = refering to my instance of Int16Collection which is the same as
the keyword this.
So because this List is actually refering to an instance of Int16Collection
I should be able to use intellisense on this List which should display Foo
as a possible member to use but
as a matter of fact it doesn't if I cast to Int16Collection this Foo is
available.
But I can't understand this if List is actually refering to an instance to
Int16Collection
this Foo should be display when the intellisense is used on List.
public class Int16Collection : CollectionBase
{
public void Test()
{
Console.Writeln (List.GetType() ); //It writes out Int16Collection
}
public void Foo()
{
}
}
I would be very glad is someone can explain this to me ?
//Tony