Skip to content

Instantly share code, notes, and snippets.

@ah01
Created June 17, 2011 21:53
Show Gist options
  • Save ah01/1032439 to your computer and use it in GitHub Desktop.
Save ah01/1032439 to your computer and use it in GitHub Desktop.
Extension Methods
using System;
// Co provede následující program?
//
// a) Vyvolá NullReferenceException
// b) Vypíše "true"
// c) Vypíše "false"
// d) To netuším, jsem Javista a tam Extension Metody nejsou :(
public static class TestProgram
{
public static void Main()
{
String s = null;
Console.WriteLine( s.IsNull() ? "true" : "false" );
}
static bool IsNull(this object @this)
{
return @this == null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment