To copy the contents of the list to the array in c#

Jitendrasoft09
Posted by Jitendrasoft09 under C# category on | Points: 40 | Views : 839
using System;
using System.Collections.Generic;

namespace MyExxample {
class JkExample {

static void Main(string[] args) {


List<string> list = new List<string>(100) {
"mango","banana",
"apple"};


string[] array = new string[list.Count];


list.CopyTo(array);


foreach (string s in array) {
Console.WriteLine("Array Item: {0}", s);
}


Console.ReadLine();
}
}
}

Comments or Responses

Login to post response