CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
try
{
List<Exception> excepcoes = new List<Exception>();
excepcoes.Add(new ArgumentException("argumento", "argumento invalido"));
excepcoes.Add(new ArgumentNullException("argumento nulo"));
excepcoes.Add(new InvalidCastException("operacao invalida"));
throw new AggregateException(excepcoes);
}
catch(AggregateException aEx)
{
foreach(var ex in aEx.InnerExceptions)
{
Console.WriteLine("{0}: {1}\n", ex.GetType(), ex.Message);
}
}
}
}