programming-examples/c-sharp/Exception/C# Program to Illustrate NullRefernce Exception.cs

23 lines
494 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Illustrate NullRefernce Exception
*/
using System;
class Program
{
static void Main()
{
try
{
string value = null;
if (value.Length == 0)
{
Console.WriteLine(value);
}
}
catch(NullReferenceException e)
{
Console.WriteLine(e.Message);
}
Console.Read();
}
}