2

I have declared the following two arrays. One is a single array of 4 elements, The other is a multidimensional array of 5 rows and 4 colums (see diagram below).

array<String^> ^single_row = {"E1", "E2", "E3", "E4"};
array<String^,2>^ multi_row=gcnew array<String^,2>(5,4);

Is there built in function I can use to copy the first array let's say the third row of the second array, without manually copying each element?
Note: I've tried array->copy but experienced error C3262: invalid array indexing: 1 dimension(s) specified for 2-dimensional 'cli::array ^'

I've attached a diagrams to assist for visualisation purposes. Array diagrams

5
  • possible dup of stackoverflow.com/questions/3902215/… Commented Feb 26, 2013 at 0:41
  • there is no memcpy for c++ clr though Commented Feb 26, 2013 at 1:27
  • maybe the way you use array->copy is incorrect. try something like Array::Copy(single_row,multi_row[3],4); specifying the row where to copy in multi_row Commented Feb 26, 2013 at 1:32
  • @stark This is not a duplicate. The link you have is of unmanaged c++ and the copy of a single arary. Commented Feb 26, 2013 at 2:51
  • @GeraldSv I get the following errors when trying Array::Copy(single_row,multi_row[3],4); Error 1 error C3262: invalid array indexing: 1 dimension(s) specified for 2-dimensional 'cli::array<Type,dimension> ^' Error 2 error C2665: 'System::Array::Copy' : none of the 5 overloads could convert all the argument types Commented Feb 26, 2013 at 2:52

1 Answer 1

1

I didn't find any function to do this. The only thing that I've found is that you can create the first array as multidimensional too.

array<String^,2> ^single_row = {{"E1", "E2", "E3", "E4"}};
array<String^,2>^ multi_row=gcnew array<String^,2>(5,4);

Then use:

Array::Copy(single_row,0,multi_row,2*4,4);

I hope this helps.

Kindest Regards

KooKoo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.