Nullable Func <T, TResult>
3 answers
Func → , ,
, (Action)
Action → , .
If you require Func to accept parameters that can be null (type NULL), or require Func to return a value that can be null (type NULL), there are no restrictions.
Example.
Func<int?, int?, bool> intcomparer =
(a,b)=>
{
if(a.HasValue &&b.HasValue &&a==b)
return true;
return false;
} ;
Func<int?, int?, bool?> nullintcomparer =
(a,b)=>
{
if(a.HasValue &&b.HasValue &&a==b)
return true;
if(!a.HasValue || !b.HasValue)
return null;
return false;
} ;
var result1 = intcomparer(null,null); //FALSE
var result2 = intcomparer(1,null); // FALSE
var result3 = intcomparer(2,2); //TRUE
var result4 = nullintcomparer(null,null); // null
var result5 = nullintcomparer(1,null); // null
var result6 = nullintcomparer(2,2); //TRUE
+1