title: Key value pairs in C# Params
body: <p>I'm looking for a way to have a function such as:</p>
  
  <pre><code>myFunction({"Key", value}, {"Key2", value});
  </code></pre>
  
  <p>I'm sure there's something with anonymous types that would be pretty easy, but I'm not seeing it.</p>
  
  <p>The only solution I can think of is to have a <code>params KeyValuePair&lt;String, object&gt;[] pairs</code> parameter, but that ends up being something similar to:</p>
  
  <pre><code>myFunction(new KeyValuePair&lt;String, object&gt;("Key", value),
             new KeyValuePair&lt;String, object&gt;("Key2", value));
  </code></pre>
  
  <p>Which is, admittedly, much uglier.</p>
  
  <p>EDIT:</p>
  
  <p>To clarify, I'm writing a <code>Message</code> class to pass between 2 different systems.  It contains a <code>ushort</code> specifying the the Message Type, and a dictionary of string to object for "Data" associated with the message.  I'd like to be able to pass all this information in the constructor, so I am able to do this:</p>
  
  <pre><code>Agent.SendMessage(new Message(MessageTypes.SomethingHappened, "A", x, "B", y, "C", z));
  </code></pre>
  
  <p>or similar syntax.</p>