In C#, why can't I modify the member of a value type instance in a foreach loop?

前端 未结 7 888
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 11:37

I know that value types should be immutable, but that\'s just a suggestion, not a rule, right? So why can\'t I do something like this:

struct MyStruct
{
             


        
7条回答
  •  情歌与酒
    2020-12-01 12:03

    I think the you can find the anwser below.

    Foreach struct weird compile error in C#

提交回复
热议问题