Reputation: 28545
Im using this in my view and want it to display only "Yes" or "No"
but its displaying False?"yes":"No"
@myPosts.Contains(item.ID)?"Yes":"No"
Whats wrong here?
Upvotes: 61
Views: 43897
Reputation: 716
You can even nest shorthand if inside of another shorthand if!
@(myPosts != null ? (myPosts.Contains(item.ID) ? "Yes" : "No") : "Null")
Upvotes: 11
Reputation: 700342
You need parentheses to use an expression:
@(myPosts.Contains(item.ID)?"Yes":"No")
Upvotes: 124