Shorthand if else with razor
You need parentheses to use an expression:
@(myPosts.Contains(item.ID)?"Yes":"No")
You can even nest shorthand if inside of another shorthand if!
@(myPosts != null ? (myPosts.Contains(item.ID) ? "Yes" : "No") : "Null")