I wrote a class with the following ctor:
public class LambdaCondition<TSource> : BaseLambdaCondition
where TSource : class, INotifyPropertyChanged
{
// (...)
public LambdaCondition(TSource source, Expression<Func<TSource, bool>> lambda, bool defaultValue)
{
// ...
}
}
I then try to use it in the following way:
A a = new A();
var condition = new LambdaCondition(a, vm => vm.Prop, false);
Compiler however complains, that I have to specify templated parameter explicitly:
A a = new A();
var condition = new LambdaCondition<A>(a, vm => vm.Prop, false);
Why isn't the compiler able to deduce template parameter, so that it doesn't have to be specified explicitly? How can i change the code, so that user of my class can take advantage of automated guessing of template parameters?