c# - Type of conditional expression cannot be determined because there is no implicit conversion between 'lambda expression' and 'lambda expression' -
i've collection of notes. depending on ui requesting notes, i'd exclude categories. example. if project notes popup requests notes, should exclude collection notes.
func<note, bool> excludecollectioncategory = (ui == uirequestor.projectnotes) ? x => x.notecategory != "collections" : x => true; //-- error: cannot convert lambda lambda
i'm getting following error: type of conditional expression cannot determined because there no implicit conversion between 'lambda expression' , 'lambda expression'
thanks helping
the compiler doesn't infer delegate types lambda expressions. need specify delegate type using cast in first ternary clause:
var excludecollectioncategory = (ui == uirequestor.projectnotes) ? (func<note, bool>)(x => x.notecategory != "collections") : x => true;
the silver lining can use var
instead of having specify type variable, isn't more verbose.
Comments
Post a Comment