title: C# String reference type passed as copy?
body: <p>I have this doubt related to C# "String" reference types .</p>
  
  <p>The following code:</p>
  
  <pre><code>string s = "lana del rey" 
  string d = s;
  s = "elvis presley";
  Console.Writeline(d);
  </code></pre>
  
  <p>Why the Output is not "elvis presley" ? If d is pointing to the same memory location of s ? </p>
  
  <p>Could you please explain this?</p>
  
  <p>A more detailed explanation of my initial question:</p>
  
  <p>All your answers were very useful.
  That question came to me with this common code sample frecuently used to explain difference between value types and reference types:</p>
  
  <pre><code>class Rectangle
  {
      public double Length { get; set; }
  }
  
  struct Point 
  {
      public double X, Y;
  }
  
  Point p1 = new Point();
  p1.X = 10;
  p1.Y = 20;
  Point p2 = p1;
  p2.X = 100;
  Console.WriteLine(“p1.X = {0}”, p1.X);
  
  Rectangle rect1 = new Rectangle
  { Length = 10.0, Width = 20.0 };
  Rectangle rect2 = rect1;
  rect2.Length = 100.0;
  Console.WriteLine(“rect1.Length = {0}”,rect1.Length);
  </code></pre>
  
  <p>In this case, the second Console.WriteLine statement will output: “rect1.Length = 100”</p>
  
  <p>In this case class is reference type, struct is value type. How can I demostrate the same reference type behaviour using a string ?</p>
  
  <p>Thanks in advance.</p>