Hi gang,

I've created an object array from a managed class.

array<MyDataType_Class^> ^Object = gcnew array <MyDataType_Class^> (3);
 Object[1] = gcnew MyDataType_Class;
 Object[1]->id = 1; 
 Object[1]->surnmame = "Formen"; 
  TextBox1->AppendText(ConvertToString(Object[1]->surname));  // Outputs "Formen"  +

The object works well and outputs expected results. However what i need is :
Calling or using this data type in some other custom functions


PS. referred class

public ref class MyDataType_Class // managed class
    int id;
    String ^surnmame; 

    MyDataType_Class() : id(0),surname(""){}

Recommended Answers

All 2 Replies

I haven't gotten into CLR C++ yet, but I'll take my best shot.

MyDataType_Class ^myFunction(String someName="",int someID=0){
    MyDataType_Class ^new Person=gcnew MyDataType_Class();
    Person->id=someID * 2; //Multiply by 2 just because
    return Person;


void SomeOtherFunction(){
    MyDataType_Class ^thisPerson=myFunction("Runcible Spoon", 21);

I haven't worked it out yet. Please give me some link to look into it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.