title: C# - Alternative to Dictionary<string, dynamic> for older versions?
body: <p>I'm trying to implement a templating class that takes in a template ID and a Dictionary with the needed objects.</p>
  
  <hr>
  
  <p>e.g.</p>
  
  <pre><code>public string GenerateMessage(string messageID, Dictionary&lt;string, dynamic&gt; values)
  {
      string gameMessage = gameMessages[messageID];
  
      var template= new StringTemplate(gameMessage);
      foreach (var value in values)
      {
          template.SetAttribute(value.Key, value.Value);
      }
      return template.ToString();
  
  }
  </code></pre>
  
  <p>usage example</p>
  
  <pre><code>var values = new Dictionary&lt;string, dynamic&gt;();
  values.Add("city", london) // instance of City
  values.Add("country", uk) // instance of Country
  values.Add("user", user) // instance of User
  string message = GenerateMessage("ID123", values);
  </code></pre>
  
  <hr>
  
  <p>Unfortunately I'm using Unity and it only supports a subset of .NET 3.5, which doesn't include dynamic!</p>
  
  <hr>
  
  <p>I really don't want to have a <code>Dictionary&lt;string, string&gt;</code> where I have to specify all the values I need, I would like to offer the templates references to the whole objects so that they can I can change the templates around with more flexibility.</p>
  
  <hr>
  
  <p>Any ideas? </p>