Qui 14 Ago 2008
O exemplo abaixo é um código que compila sem problema algum, porém, durante a sua execução lança a exceção System.ArrayTypeMismatchException na linha em que o inteiro 1 é atribuído a posição 0 do array b.
using System;
namespace CompilerTypeCheck
{
class Program
{
static void Main(string[] args)
{
try
{
string[] a = new string[3];
object[] b = a;
b[0] = 1;
}
catch (System.ArrayTypeMismatchException atmex)
{
System.Console.WriteLine("An error occured while executing this program. Error details: " + atmex.StackTrace);
}
System.Console.WriteLine("Press to exit…”);
System.Console.ReadLine();
}
}
}

Enviar por e-mail. Hits para esta publicação: 105.