Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nullable Func<T, TResult>

Tags:

c#

func

In C# is it possible to pass a method a nullable Func?

Neither Func<A, bool>? nor Func?<A, bool> is working.

like image 992
Sachin Kainth Avatar asked May 15 '12 14:05

Sachin Kainth


2 Answers

That doesn't make sense.
All reference types, including Func<...>, can already be null.

Nullable types apply to value types (structs), which cannot ordinarily be null.

like image 88
SLaks Avatar answered Sep 29 '22 15:09

SLaks


A Func is a delegate which is a reference type. This means it is already nullable (you can pass null to a method).

like image 36
Andreas Schlapsi Avatar answered Sep 29 '22 15:09

Andreas Schlapsi