Given a type declared as shown below
public class EqualityProbe<T>
{
public EqualityProbe( Func<T> functionToGetActualValue, T expectedValue, string probeDescription) {..}
Client code:
// cannot infer bool here
new EqualityProbe(CanConnectToMachine, true, "Probe machine is online")
// compiles fine
new EqualityProbe<bool>(CanConnectToMachine, true, "Probe machine is online")
My understanding is that type-inference doesn't work for method groups (e.g. CanConnectToMachine) or anonymous methods (lambda expressions).
But in this case, why doesn't the compiler infer the type argument from the second argument