It is not for casting. It is just the conditional operator, an easy syntax to do an if-else code block. So if the expression before ? returns true, it executes the first expression ( the one followed by ?) and return the value and if the expression before ? returns false, it returns the return value of the second expression (followed by :)
So in your case, If the value of the expression user.EmailConfirmed is true the code will be same as
new Claim(JwtClaimTypes.EmailVerified, "true" , ClaimValueTypes.Boolean)
else (if it is false)
new Claim(JwtClaimTypes.EmailVerified, "false" , ClaimValueTypes.Boolean)
You can also call the ToString() method on the boolean value and then call ToLower() method to get true or false . If you ever want to try that, Here is how you do it
new Claim(JwtClaimTypes.EmailVerified, user.EmailConfirmed.ToString().ToLower(),
ClaimValueTypes.Boolean)
I would personally prefer the first approach ( conditional operator), but probably replace the magic strings with some constants