Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Convert/cast System::Array class to List

Convert/cast System::Array class to List

Scheduled Pinned Locked Moved Managed C++/CLI
questiondata-structuresannouncement
3 Posts 3 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yehiga1467
    wrote on last edited by
    #1

    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]);
    }

    V Richard Andrew x64R 2 Replies Last reply
    0
    • Y yehiga1467

      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]);
      }

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • Y yehiga1467

        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]);
        }

        Richard Andrew x64R Online
        Richard Andrew x64R Online
        Richard Andrew x64
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups