google code prettify

2015年6月2日 星期二

[LINQ] OfType-Basic

[LINQ] OfType-Basic



public void Linq57() {
    object[] numbers = { null, 1.0, "two", 3, "four", 5, "six", 7.0 };

    var doubles = numbers.OfType<double>();
 
    Console.WriteLine("Numbers stored as doubles:");
    foreach (var d in doubles) {
        Console.WriteLine(d);
    }    
}



output:
Numbers stored as doubles:
1
7

沒有留言:

張貼留言