Created
May 13, 2012 21:49
-
-
Save sherpc/2690395 to your computer and use it in GitHub Desktop.
Null tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace NullTest | |
{ | |
class SomeClass | |
{ | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
TestNullArgument(new SomeClass()); | |
TestNullArgument((SomeClass)null); | |
} | |
static void TestNullArgument(SomeClass arg) | |
{ | |
bool isNull = arg == null; | |
Console.WriteLine("Arg is null: {0}", isNull); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace NullTest | |
{ | |
class SomeClass | |
{ | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
TestNullArgument(new SomeClass()); | |
TestNullArgument(); | |
/ } | |
static void TestNullArgument(SomeClass arg = null) | |
{ | |
bool isNull = arg == null; | |
Console.WriteLine("Arg is null: {0}", isNull); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment