I have the following 2 helper methods:
public static U IfNotNull<T, U>( this T instance, Func func) where T : class
return instance != null ? func(instance) : default(U);
public static void IfNotNull]]>( this T instance, Action action) where T : class
if (instance != null)
When trying to use the one with the Action]]> call resharper says it can also use the Func one with the second argument as void, but then complains that void can't be used, the code compiles fine though, for now I specify the generic part myself to resharper knows which one to use.