The CLR doesn't enforce semantics of type names.
So yes, Predicate<T>
is just a delegate taking a T
and returning a bool
, but it's meant to be used in places where a predicate (a test for a certain condition) is expected. It's up to the programmer to respect that convention. If you need a similar delegate without a predefined semantic meaning, you could use Func<T, bool>
, for example.
To the compiler, there is no functional difference between a Predicate<T>
or a Func<T, bool>
. But to another developer reading your code, it provides an important hint as to what your code is supposed to do, provided you used it correctly.
Similarly, there's nothing to stop me from using System.DayOfWeek
to store an arbitrary value between 1 and 7 that doesn't actually represent a day of the week. It would be a stupid thing to do, but the compiler will certainly let me. It's up to you to make sure your code makes sense, the compiler can't do that for you.