欢迎加我的QQ群:193522571,一起来讨论、交流!

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();
        }
    }
}

 

posted @ 2014-07-12 15:37  swtool  阅读(340)  评论(0编辑  收藏  举报
欢迎加我的QQ群:193522571,一起来讨论、交流!