using System;
using System.Collections;
namespace Articulos.Cap04.Excepciones.Parte5
{
public sealed class UsoNullReferenceException
{
public static void Main()
{
// Define una variable de tipo ArrayList, sin embargo
// aún no ha sido inicializada. Sólo con null:
ArrayList al = null;
try
{
// Intento de agregar un elemento a la
// variable ArrayList:
al.Add ("Blog xCSw");
}
catch (NullReferenceException mre)
{
Console.WriteLine ("Mensaje de error: `{0}`", mre.Message);
}
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnM7CgpuYW1lc3BhY2UgQXJ0aWN1bG9zLkNhcDA0LkV4Y2VwY2lvbmVzLlBhcnRlNQp7CiAgICBwdWJsaWMgc2VhbGVkIGNsYXNzIFVzb051bGxSZWZlcmVuY2VFeGNlcHRpb24KICAgIHsKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCiAgICAgICAgewogICAgICAgICAgICAvLyBEZWZpbmUgdW5hIHZhcmlhYmxlIGRlIHRpcG8gQXJyYXlMaXN0LCBzaW4gZW1iYXJnbyAKICAgICAgICAgICAgLy8gYcO6biBubyBoYSBzaWRvIGluaWNpYWxpemFkYS4gU8OzbG8gY29uIG51bGw6CiAgICAgICAgICAgIEFycmF5TGlzdCBhbCA9IG51bGw7CiAgICAgICAgICAgIAogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgLy8gSW50ZW50byBkZSBhZ3JlZ2FyIHVuIGVsZW1lbnRvIGEgbGEgCiAgICAgICAgICAgICAgICAvLyB2YXJpYWJsZSBBcnJheUxpc3Q6CiAgICAgICAgICAgICAgICBhbC5BZGQgKCJCbG9nIHhDU3ciKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoTnVsbFJlZmVyZW5jZUV4Y2VwdGlvbiBtcmUpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgiTWVuc2FqZSBkZSBlcnJvcjogYHswfWAiLCBtcmUuTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0=