首页 > 代码库 > LinQ转换运算符OfType<T>

LinQ转换运算符OfType<T>

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace OfTypeDemo{    class Program    {        static void Main(string[] args)        {            var numbers = new object[] { 1, "two", null, "3", 4 };            foreach (var anInt in numbers.OfType<int>())                Console.WriteLine(anInt);            Console.ReadLine();        }    }}