Convert Object to Array C++/CLi

2019-08-17 03:17发布

问题:

I am using VS2010, windows forms application(C++)

array<int>^ MyArray = gcnew array<int>(10){1,2,3,4,5,6,7,8,9,10};
Object^ MyObj = MyArray;

But when I try to get MyObj->Length I get error.

U may ask why do I need an object? The answer is, the main goal is to create a Dictionary Put any type value in it and be able to get access to read, edit etc.

Dictionary<String^, Object^>^ MyDic = gcnew Dictionary<String^, Object^>;
    array<int>^ MyArray = gcnew array<int>(10){1,2,3,4,5,6,7,8,9,10};
    MyDic["ArrayInDictionary"] = MyArray;
    MyDic["ArrayInDictionary"]->Length;
标签: c++-cli