Shorthand if else with razor March 28, 2023 by Tarik You need parentheses to use an expression: @(myPosts.Contains(item.ID)?"Yes":"No")