What is the meaning of "immutable" when relating to an Int32 ?
Int32 i = 0;
i++;
//etc
What is the meaning of "immutable" when relating to an Int32 ?
Int32 i = 0;
i++;
//etc
Take a look at this post:
Be sure to read the comments under the second post - goes into a lot of detail concerning your question.
The types are immutable, meaning you can't change their value. 3 = 3 no matter what you want it to be. The variable i in your example isn't immutable, it can be any Int32 value. But as was said, the value itself cannot be changed.
And as was said in the link, generally you use a struct to represent an immutable object. The .Net framework follows this 'rule' (DateTime for example). Methods on the struct return a new struct, they don't modify the one you have.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.