Convert/cast System::Array class to List
-
How do I convert array to list?
array^ My1DArray = gcnew array(100);
to
List^ temp
temp = My1DArray.ToList(); //doesn't work
Update: I am currently using a for loop to copy data 1 by 1, if there's no other faster way ,i'll stick with this for now . Thanks!
array^ My1DArray = gcnew array(100);
int^ bytesToRead = gcnew(int);
*bytesToRead = SerialPort->BytesToRead;
SerialPort->Read(My1DArray, 0, *bytesToRead);
SerialPort->DiscardInBuffer();List^ temp = gcnew List;
int^ counter = gcnew (int);
for (*counter = 0; *counter < *bytesToRead; (*counter)++) {
temp->Add(My1DArray[*counter]);
} -
How do I convert array to list?
array^ My1DArray = gcnew array(100);
to
List^ temp
temp = My1DArray.ToList(); //doesn't work
Update: I am currently using a for loop to copy data 1 by 1, if there's no other faster way ,i'll stick with this for now . Thanks!
array^ My1DArray = gcnew array(100);
int^ bytesToRead = gcnew(int);
*bytesToRead = SerialPort->BytesToRead;
SerialPort->Read(My1DArray, 0, *bytesToRead);
SerialPort->DiscardInBuffer();List^ temp = gcnew List;
int^ counter = gcnew (int);
for (*counter = 0; *counter < *bytesToRead; (*counter)++) {
temp->Add(My1DArray[*counter]);
}why do you care about any "other faster way"? How long is/are the array(s) to be converted? How often are you going to convert it/them?
-
How do I convert array to list?
array^ My1DArray = gcnew array(100);
to
List^ temp
temp = My1DArray.ToList(); //doesn't work
Update: I am currently using a for loop to copy data 1 by 1, if there's no other faster way ,i'll stick with this for now . Thanks!
array^ My1DArray = gcnew array(100);
int^ bytesToRead = gcnew(int);
*bytesToRead = SerialPort->BytesToRead;
SerialPort->Read(My1DArray, 0, *bytesToRead);
SerialPort->DiscardInBuffer();List^ temp = gcnew List;
int^ counter = gcnew (int);
for (*counter = 0; *counter < *bytesToRead; (*counter)++) {
temp->Add(My1DArray[*counter]);
}Why are you using int's through handles and gcnew? Why don't you just say
Int32 bytesToRead = 0;
Int32 counter = 0;??
The difficult we do right away... ...the impossible takes slightly longer.