+ Reply to Thread
Results 1 to 2 of 2

Thread: How can i copy array elements to a list

  1. #1
    Junior Member
    Join Date
    May 2012

    How can i copy array elements to a list

    I have an array of elements , i need to copy these elements to a list
    but the only option i know is looping through each element in the array and add it to list
    is there any other faster option because my array is too big and takes some time to load all
    elements into list.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    You can do it by putting the array name inside the list object like that :
    	int[] arr = new int[3]; // New array with 3 elements
    	arr[0] = 2;
    	arr[1] = 3;
    	arr[2] = 5;
    	List<int> list = new List<int>(arr); // Copy array elements to List

+ Reply to Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts