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: 
That's not specific to string, that's the case of any parameter. If you want to change the variable passed in a parameter, you need to pass it by reference.

When passing by value, you can only change the contents of the passed in instance of a reference type. And string has no mutable content.
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.
}

```