property overloading

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm converting a project from MC++ to C++/CLI but can't figure out how to
convert this overloded property:

__property void set_Item(String *key, Object *value);
__property Object *get_Item(String *key);
__property void set_Item(String *key, int index, Object *value);
__property Object *get_Item(String *key, int index);
 
Terje,
I'm converting a project from MC++ to C++/CLI but can't figure out how to
convert this overloded property:

__property void set_Item(String *key, Object *value);
__property Object *get_Item(String *key);
__property void set_Item(String *key, int index, Object *value);
__property Object *get_Item(String *key, int index);

Try this:

property Object^ Item[String^] {
Object^ get(String^ key) { return nullptr; }
void set(String^ key, Object^ value) { }
}

property Object^ Item[String^,int] {
Object^ get(String^ key, int index) { return nullptr; }
void set(String^ key, int index, Object^ value) { }
}

If you wanted to turn it into a default indexed property, then just make it
this way:
property Object^ default[String^] {
Object^ get(String^ key) { return nullptr; }
void set(String^ key, Object^ value) { }
}

property Object^ default[String^,int] {
Object^ get(String^ key, int index) { return nullptr; }
void set(String^ key, int index, Object^ value) { }
}
 
Back
Top