Yes if it is interned ... there are many reasons why one would not want to do it in place .... the point was just that you can :)
On 9/21/07, Frans Bouma <[EMAIL PROTECTED]> wrote: > > You certainly can ... here is an example from a few years ago when > > people were trying to find the fastest way of reversing a string > > http://codebetter.com/blogs/gregyoung/archive/2006/07/21/147569.aspx > > I was thinking about this a bit, and one question popped in my mind > (as I don't know the exact answer): if you reverse a constant string via an > unsave char pointer voodoo loop, aren't you then altering that constant string > EVERYWHERE in your app? As constant strings are interned by default? > > so: > string s = "foo"; > // reverse s in-place here inline > Console.WriteLine(s); > Console.WriteLine("foo"); > > will this print: > oof > oof > > ? > > FB > > > > > On 9/21/07, Stoyan Damov <[EMAIL PROTECTED]> wrote: > > > On 9/21/07, Mark Nicholls <[EMAIL PROTECTED]> wrote: > > > > On Fri, 21 Sep 2007 16:31:17 +0100, Graeme Bradbury > > > > <[EMAIL PROTECTED]> wrote: > > > > > > > > >1. It can't be done in place due to immutable type, and if you give it > as > > > > >array of chars then Array.Reverse(...); > > > > > > > > damn...as Mr Bouma pointed out....I didn't think.... > > > > > > > > > > No, he was wrong ;) you *can* in an unsafe method, using fixed (char* ...) > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > -- Studying for the Turing test =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
