Listnums = new List { 1, 2, 3 }; int[] arr = nums.ToArray();
int[] nums = { 1, 2, 3, 4, 5 }; int[] evenNums = nums.Where(x => x % 2 == 0).ToArray();This example shows how ToArray is used in LINQ operations. The Where method filters an integer array to keep only the even numbers. The ToArray method is used to convert the result into a new integer array. Package Library: System.Runtime.dll