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

 

相关文章:

  • 2021-08-11
  • 2022-12-23
  • 2021-11-01
  • 2021-11-12
  • 2022-02-11
  • 2022-12-23
  • 2021-05-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案