Calling the ToArray Operator : ToArray « LINQ « C# / C Sharp






Calling the ToArray Operator

 

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass {
    public static void Main() {
        string[] presidents = {"G", "H", "a", "H", "over", "Jack"};

        string[] names = presidents.OfType<string>().ToArray();
        foreach (string name in names)
            Console.WriteLine(name);
    }
}

 








Related examples in the same category

1.Convert query to array with ToArray
2.Use Conversion Operators ToArray
3.generates an array of double values by first using a query expression with orderby
4.To List: convert query result to list
5.Convert query result to an Array