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