By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,961 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,961 IT Pros & Developers. It's quick & easy.

What is a mutable type?

P: n/a
Hi

I wonder if someone could explain the above to me. The examples I've
seen seem to indicate that it is effectively a read-only class, but I'm
sure that's being over simplistic. But what is the significance of them?

Thanks

Simon
Oct 25 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
mutable: capable or subject to change

I think you are thinking of immutable. Strings are immutable.
--
Terry
"Simon Woods" wrote:
Hi

I wonder if someone could explain the above to me. The examples I've
seen seem to indicate that it is effectively a read-only class, but I'm
sure that's being over simplistic. But what is the significance of them?

Thanks

Simon
Oct 25 '07 #2

P: n/a
Forgot about 'what is the signicance'.

Most things are mutable, its the immutable things that have to be handled
differently.

Sub Main()
Dim s1 As String = "123"
Dim s2 As String = s1
Console.WriteLine("{0}", (s1 Is s2))
s1 = s1 & "45"
Console.WriteLine("{0}", (s1 Is s2))
Console.ReadLine()
End Sub
The output is
True
False
So when you attemped to change s1, a brand new string object was created
with value "12345" and s1 points to it.

--
Terry
"Terry" wrote:
mutable: capable or subject to change

I think you are thinking of immutable. Strings are immutable.
--
Terry
"Simon Woods" wrote:
Hi

I wonder if someone could explain the above to me. The examples I've
seen seem to indicate that it is effectively a read-only class, but I'm
sure that's being over simplistic. But what is the significance of them?

Thanks

Simon
Oct 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.