"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Peter Duniho <Np*********@NnOwSlPiAnMk.comwrote:
>Smithers wrote:
Are delegates value types or reference types? I was just pondering the
fact
that delegates are immutable... Does this mean that they are value
types and
not reference types?
No, they are a reference type.
Immutable doesn't mean it has to be a value type. And something that is
a value type is not required to be immutable. The two often go
hand-in-hand, but they are not actually the same thing, and there are in
fact counter-examples of each in the .NET Framework (the String class,
for example).
Peter:
I still miss the copy-on-write semantics for strings I loved in Delphi.
While I know C# and even .NET says strings are immutable,
Do you know if the CLR treats strings as smart?
I hope Nicholas Paldino reads this, as he'd be sure to know. =)
>
The difference being that while immutable reference types are
reasonably common and perfectly reasonable, making value types mutable
is almost *always* a bad idea, and can result in some very confusing
behaviour!
Hmm. Give me an example of when it would be almost a good idea. =)
--
Jon Skeet - <sk***@pobox.com>
- Michael Starberg