Dictionary values by reference
<p>In our application we have some strings coming from translation that can contain variables. For example in <code>Can i have a {beverage}?</code> the <code>{beverage}</code> part should be replaced with a variable. 
My current implementation works by having a Dictionary of the name and value of all variables, and just replacing the correct string. However i'd like to register the variables by reference, so that if the value is ever changed the resulting string is changed as well. Usually passing a parameter with the <code>ref</code> keyword would do the trick, but i'm unsure on how to store those in a Dictionary. </p>

<p>TranslationParser:</p>

<pre><code>static class TranslationParser
{
    private const string regex = "{([a-z]+)}";
    private static Dictionary&lt;string, object&gt; variables = new Dictionary&lt;string,object&gt;();

    public static void RegisterVariable(string name, object value)
    {
        if (variables.ContainsKey(name))
            variables[name] = value;
        else
            variables.Add(name, value);
    }

    public static string ParseText(string text)
    {
        return Regex.Replace(text, regex, match =&gt;
        {
            string varName = match.Groups[1].Value;

            if (variables.ContainsKey(varName))
                return variables[varName].ToString();
            else
                return match.Value;
        });
    }
}
</code></pre>

<p>main.cs</p>

<pre><code>        string bev = "cola";
        TranslationParser.RegisterVariable("beverage", bev);
        //Expected: "Can i have a cola?"
        Console.WriteLine(TranslationParser.ParseText("Can i have a {beverage}?")); 
        bev = "fanta";
        //Expected: "Can i have a fanta?"
        Console.WriteLine(TranslationParser.ParseText("Can i have a {beverage}?")); 
</code></pre>

<p>Is this possible at all, or am i just approaching the problem incorrectly? I fear that the only solution would involve unsafe code (pointers).</p>

<p>So in short, i'd like to store a variable in a Dictionary, change the original variable and get the changed value from the Dictionary. Like you would do with the <code>ref</code> keyword. </p>
