Skip to content

Weird system.linq.expressions behavior with regard to interned vs. non-interned strings #70962

Answered by elgonzo
elgonzo asked this question in Q&A
Discussion options

You must be logged in to vote

@EgorBo

your expression compares objects by reference

If that were the case, the three cases i outlined in my report should all evaluate to false (because strLeft and strRight are separate string instances in every of these three cases), no?

How exactly does it happen that if the strLeft string is interned the expression evaluates to true, otherwise to false? Reference comparison does not explain this behavior.

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@EgorBo
Comment options

EgorBo Jun 19, 2022
Collaborator

Comment options

You must be logged in to vote
1 reply
@EgorBo
Comment options

EgorBo Jun 19, 2022
Collaborator

Answer selected by elgonzo
Comment options

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

@elgonzo
Comment options

@EgorBo
Comment options

EgorBo Jun 20, 2022
Collaborator

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