Why are lambda expressions not “interned”?

前端 未结 6 928
-上瘾入骨i
-上瘾入骨i 2021-01-01 19:22

Strings are reference types, but they are immutable. This allows for them to be interned by the compiler; everywhere the same string literal appears, the same objec

6条回答
  •  忘掉有多难
    2021-01-01 20:10

    Lambdas can't be interned because they use an object to contain the captured local variables. And this instance is different every time you you construct the delegate.

提交回复
热议问题