ReSharper is good tool, it taught me the auto property in .NET 3.5 today.
// traditional property declaration
public class Foo
{
private string _name;
public string Name
{
get { return _name; }
set [...]
Return null if the value type object has default value.
public static T? GetValueOrNull<t>( this T value ) where T : struct
{
if( value.Equals( default( T ) ) )
return new Nullable<t>();
else
return value;
}
// Usage
int i = default(int); //0
int? i = i.GetValueOrNull();
Console.Writeline( i.HasValue );
// output: false
Continue reading about C# Extension method, GetValueOrNull for value type object