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?
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?
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")