Sorry for opening up this task again.
I want to fully understand this List that is return from CollectionBase.
According to you is List in CollectionBase implemented something like the
below which you sent me previously. So the referenced type for List that
will be
returned at execution time must be CollectionBase. The compile type for List
is IList
But when I looked at it by using method Test in Int16Collection(see below) I
get that the referenced type at execution type is Int16Collection.
So the referenced type from CollectionBase for List is not the same as the
referenced type for List when I use GetType in method Test.
Can you explain whay the types are not the same?
< protected IList List
{public class Int16Collection : CollectionBase
get
{
return this;
}
}
{
public void Test()
{
Console.Writeln(List.GetType()); //It writes out Int16Collection
}
}
//Tony
"Jon Skeet [C# MVP]" <sk***@pobox.comskrev i meddelandet
news:MP*********************@msnews.microsoft.com. ..
Tony Johansson <jo*****************@telia.comwrote:Have I misunderstood this.
If I use List.GetType it must mean that what is List refering to at
execution type and here
I get Int16Collection as an answer.
Is that correct?
Yes.
So in that case what do you mean with this "The List property of
CollectionBase always returns "this" (i.e. the
same instance)." ?
I mean that the List property is implemented as:
protected IList List
{
get
{
return this;
}
}
--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com