Question: **Class is a reference types while Struct is a value type.**

This means that I do not need to explicitly specify ref for every parameter which is a type of class.

My Question is,

Why do we have to specify a ref keyword for a string type which is basically a type of class ?

Please find the example below

```
public partial class StringManupulation : Form
{
    public StringManupulation()
    {
        InitializeComponent();

        String value = "Hello ";

        Concatenate( value );
        MessageBox.Show( value );

        Concatenate( ref value );
        MessageBox.Show( value );
    }

    /// <summary>
    /// Does not work
    /// </summary>
    /// <param name="value"></param>
    public void Concatenate( String value )
    {
        value = string.Concat( value, "StackOverflow" );
    }

    /// <summary>
    /// Works! 
    /// </summary>
    /// <param name="value"></param>
    public void Concatenate( ref String value )
    {
        value = string.Concat( value, "StackOverflow" );
    }
 }

```

Answer: 
`System.String` is immutable - That means you cannot change the content of string once it is assigned. You may try `System.Text.StringBuilder` (mutable object) instead of `System.String` class.

```
static void ParamTest(System.Text.StringBuilder  paramSb)
{
  paramSb.Append("World");
}

static void Main()
{
  System.Text.StringBuilder sb = new StringBuilder();
  sb.Append("Hello");

  ParamTest(sb);
  Console.WriteLine(sb);
}

```

Have a look at [Strings in C# and .NET](http://csharpindepth.com/Articles/General/strings.aspx) and [article](http://www.yoda.arachsys.com/csharp/parameters.html) - chapter from C# in Depth.

Quote to [Jon Skeet](http://csharpindepth.com/Articles/General/strings.aspx)

> 
> It is a reference type? 
> 
> 
> It's a common misconception that string is a
>  value type. That's because its immutability (see next point) makes it
>  act sort of like a value type. It actually acts like a normal
>  reference type. See my articles on parameter passing and memory for
>  more details of the differences between value types and reference
>  types.
> 
> 
>
You have to use the ref keyword when you assign new reference to a variable.

```
class A {
    public string prop { get; set; }
}

public void test(A a)
{
    a = new A(); // NO, it's a new ref
    a.prop = "foo"; // Yes, you modify the object it's not a new ref.
}

public void test2(string s)
{
    s = "bar"; // Equivalent to s = new String("bar"), so it's a new ref.
}

```