Languages
[Edit]
EN

C#/.NET - convert List to Array

13 points
Created by:
AnnLen
1795

In C#/.NET it is possible to convert List to array in fast way with ToArray method.

List<string> list = new List<string>()
{
	"A", "B", "C"
};

string[] array = list.ToArray();

for(int i = 0; i < array.Length; ++i)
	Console.Write(array[i] + " ");

Output:

A B C 

References

  1. List<T>.ToArray - Microsoft Docs
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.