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
沒有留言:
張貼留言