Daniel Lidström wrote:
> When I try this I get the following compile error:
> error C2392: 'LX::Units __gc *LX::UnitsCollection::get_Item(int)' :
[quoted text clipped - 12 lines]
> And put [System::Reflection::DefaultMemberAttribute("Index")] attribute on
> the UnitsCollection class?
Yes.
The compiler thinks you're trying to override ArrayList's get_Item
method (which is virtual) instead of replacing it, since yours has the
same parameters, but the return type differs so you get an error. In C#,
you could use the 'new' keyword to hide the inherited member instead of
overriding it, but I don't think MC++ has an equivalent.
> Is this how I use the default accessor? It compiles anyhow.
>
> UnitsCollection* units = new UnitsCollection;
> Units* unit = new Units();
> units->Index[0] = unit;
Yes.
In MC++ the default accessor is no different from any other indexed
property. The [DefaultMember] attribute only affects other languages
such as C#.
Jesse