managed class index property

G

Guest

I have this funny problem defining a C++ (VC++ 2002) managed class index
property:

public: __property virtual String __gc *get_Prefixes(int aiIndex) {
return m_pDatasetList->Prefixes[aiIndex].c_str();
}

or

public: __property String __gc *get_Prefixes(int aiIndex) {
return m_pDatasetList->Prefixes[aiIndex].c_str();
}

It does not get resolved to a property but stays a method get_Prefixes()
when viewed in C# (2003) object browser.
But I expect it something like this "Prefixes[number]"

Other none indexed poperties defined in that same class does get resolved to
properties.

Any idea what I do wrong? The examples show me that I do make it correct.
 
J

Jesse McGrew

I have this funny problem defining a C++ (VC++ 2002) managed class index
property:

....

It does not get resolved to a property but stays a method get_Prefixes()
when viewed in C# (2003) object browser.
But I expect it something like this "Prefixes[number]"

Other none indexed poperties defined in that same class does get resolved to
properties.

Any idea what I do wrong? The examples show me that I do make it correct.

There's nothing wrong with your code; the problem is that C# doesn't
support indexed properties. It only supports indexers - the equivalent
of "operator []".

Try applying the attribute
[System::Runtime::CompilerServices::IndexerName(S"Prefixes")] to your
class to make C# see Prefixes as an indexer.

Jesse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top