MC++ FAQ
Thursday 07 | 18 | 2002
Defining Indexers
Managed C++, supports multiple indexed properties defined on a class. C#, on the other hand, supports only Indexers.

However, an Indexer is nothing more than the default indexed property on a class. If you're writing an MC++ library to consume later in C#, and want to provide indexers for your classes, you can mark one of your indexed properties as the default member for that class.

You can do this by using the DefaultMemberAttribute attribute on your MC++ class. Here's a short example:

[ DefaultMember("Item") ]
public __gc class ClassWithIndexer
{
public:
   __property int get_Item(int index) {
      return index*2;
   }

};
Posted by tomasr at July 18, 2002 03:31 AM
Comments
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?

Copyright(C) 2002, Tomas Restrepo, All rights reserved. Powered by Movable Type 2.63