Joey
Fri Aug 20 03:43:10 CDT 2004
It's very interesting to have guys like you here. Good thing I posted my
views here so I got my notions corrected especially with the Immutability of
Strings (be it special or not, :p).
Thanks a lot guys.
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1b8fbf4e6c0d887698b201@msnews.microsoft.com...
> Cor Ligthert <notfirstname@planet.nl> wrote:
> > > Not really. There's nothing special about string here. It's just an
> > > immutable object, like any other immutable object one could design.
> > >
> > > There *are* ways in which the CLR treats strings in a special manner,
> > > but this isn't one of them.
> >
> > What do I miss?
> >
> > In my opinion is the reason is from the behaviour is that the string is
> > passed by its value of the pointer to its starting adres and by a change
get
> > a new pointer.
> >
> > While the dataset keeps its own pointer
>
> No, DataSet doesn't "keep its own pointer". In both cases, they're just
> reference types. You can't change the contents of a string, you can
> change the contents of a DataSet. In both cases, changing the value of
> a variable won't change the object though. In other words:
>
> DataSet x = GetSomeDataSet();
> x = GetSomeOtherDataSet();
>
> doesn't change either DataSet - it just changes the value of x from a
> reference to one DataSet to a reference to another DataSet.
>
> > Your answer is therefore not wrong, however I would not completly answer
it
> > like you do. There is something special to the string, it is immutable
and
> > therefore it gets evertime a new pointer.
>
> But being immutable has nothing to do with the CLR. You can write your
> own immutable classes which behave exactly the same way.
>
> > As we disscussed before not all systems have immutable strings, so you
may
> > call this something "special" from Net. (And let us not discuss about
the
> > word special, maybe is not immutable at the moment "special").
> >
> > Correct me when I am "completly" wrong?
>
> What's wrong is the impression that strings are handled differently to
> other types in this respect. They're not at all. String is a reference
> type which happens to be immutable. The immutability just means there
> isn't any way to change the contents of the object, but that doesn't
> mean the CLR handles it differently or anything like that. (Not in this
> respect, anyway - interning etc is a different matter.)
>
> --
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too