List to array c#

array to list
In this post we will se how to convert list to array.We need to convert list to array many times in C# programming. Converting list to array can be done by various ways. We are going to see C# examples to convert the list to array.

we will see the way to convert list to an array. we use .ToArray() parameter less instance method that converts list to an array. Below example shows how list get converted in to array using .ToArray() method:

Example to convert list to array [C#]

using System;
using System.Collections.Generic;

class Program
 static void Main()
  // List to convert into Array.
  List<string> lstString = new List<string>();
  // use .ToArray() Method to convert list to array
  string[] strArray = lstString.ToArray();


Post a Comment