What is the meaning of "immutable" when relating to an Int32 ?

Int32 i = 0;
i++;
//etc

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.