
Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
That deserves further explanation. The code snippet I gave is the textbook
way to create a type-safe collection pre-Whidbey is it not? You derive from
System.Collections.CollectionBase and then, among other things, you can
override get_Item(int index) and do a cast of List->item[index] from
System.Object * to the type that you're making a collection of. This is
straight out of the documentation.
I realize that as of Whidbey there are superior ways to do type-safe
collections, but are you saying that code written to follow the past
recommended practice for creating type-safe collections will not even
compile in Whidbey? Is CollectionBase being removed from the framework
then? There doesn't seem to be much point in keeping it if the compilers
won't let you use it as intended.
Bern McCarty
Bentley Systems, Inc.
> Hi Bern,
>
[quoted text clipped - 14 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
Gary Chang - 13 May 2004 03:22 GMT
Hi Bern,
Our dev team has provided an example in the new syntax of doing the
explicit interface implementation which is how you write a typesafe
collection in generic-less CLR:
ref class R : ICloneable {
int X;
virtual Object^ C() = ICloneable::Clone {
return this->Clone();
}
public:
R() : X(0) {}
R(int x) : X(x) {}
virtual R^ Clone() new {
R^ r = gcnew R;
r->X = this->X;
return r;
}
};
Wish it helps!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Bern McCarty - 13 May 2004 13:48 GMT
Thanks Gary. I'll have to study the C++/CLI draft to try to understand that
code. Meanwhile, could you provide an example of how to do the same thing
using /clr:oldsyntax ?
Bern McCarty
Bentley Systems, Inc.
> Hi Bern,
>
[quoted text clipped - 29 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
Ronald Laeremans [MSFT] - 13 May 2004 19:11 GMT
Hi Bern,
That isn't possible in a direct way since the 7.0/7.1 syntax does not
support explicit interface implementation.
Ronald Laeremans
Visual C++ team
> Thanks Gary. I'll have to study the C++/CLI draft to try to understand
> that
[quoted text clipped - 38 lines]
> rights.
>> --------------------