The List ToArray() method is a conversion method that can be used to create an array from a List. It is a part of the System.Windows.Documents package library.
Example 1:
List numbers = new List { 1, 2, 3, 4, 5 }; int[] numArray = numbers.ToArray();
In the above example, a List object "numbers" is initialized with 5 integer values. The ToArray() method is then called on the List object to convert it to an array "numArray" containing the same values.
Example 2:
List fruits = new List { "apple", "banana", "cherry" }; string[] fruitArray = fruits.ToArray();
In the above example, a List object "fruits" is initialized with 3 string values. The ToArray() method is then called on the List object to convert it to an array "fruitArray" containing the same values.
Both of these examples demonstrate how the List ToArray() method can be used to quickly and easily convert a List to an array. The package library used in the examples is System.Windows.Documents.
C# (CSharp) System.Windows.Documents List.ToArray - 30 examples found. These are the top rated real world C# (CSharp) examples of System.Windows.Documents.List.ToArray extracted from open source projects. You can rate examples to help us improve the quality of examples.