CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public static void Test(Version version)
{
Console.WriteLine("is a version");
}
public static void Test(FormatException formatException)
{
Console.WriteLine("is a formatException");
}
public static void Main()
{
var list = new List<object>();
list.Add(new Version());
list.Add(new FormatException());
foreach (var item in list)
{
Test((dynamic)item);
}
}
}