prints all of the elements of an array that are of type double : OfType : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » OfType »

 

prints all of the elements of an array that are of type double








    
 


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

public class MainClass {
    public static void Main() {
        object[] numbers = { null, 1.0, "two", 3, 4.0f, 5, "six", 7.0 };
        var doubles = numbers.OfType<double>();
        Console.WriteLine("Numbers stored as doubles:");
        foreach (var d in doubles) {
            Console.WriteLine(d);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» OfType