Skip to content
Discussion options

You must be logged in to vote

The expression does short-circuit. That's not the problem. The issue is that the expression by itself is evaluated before the assignment, which is when the conversion operation occurs. The conditional expression false ? TestClass : default evaluates to a TestClass, not an int, and the default value of a TestClass is null.

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
5 replies
@Arc-huangjingtong
Comment options

@HaloFour
Comment options

@TahirAhmadov
Comment options

@TahirAhmadov
Comment options

@Arc-huangjingtong
Comment options

Comment options

You must be logged in to vote
3 replies
@HaloFour
Comment options

Answer selected by Arc-huangjingtong
@Arc-huangjingtong
Comment options

@huoyaoyuan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants