title: Casting C# out parameters?
body: <p>Is it possible to cast out param arguments in C#?  I have:</p>
  
  <pre><code>Dictionary&lt;string,object&gt; dict;  // but I know all values are strings
  string key, value;
  </code></pre>
  
  <p>Roughly speaking (and if I didn't have static typing) I want to do:</p>
  
  <pre><code>dict.TryGetValue(key, out value);
  </code></pre>
  
  <p>but this obviously won't compile because it "cannot convert from 'out string' to 'out object'".  </p>
  
  <p>The workaround I'm using is:</p>
  
  <pre><code>object valueAsObject;
  dict.TryGetValue(key, out valueAsObject);
  value = (string) valueAsObject;
  </code></pre>
  
  <p>but that seems rather awkward.</p>
  
  <p>Is there any kind of language feature to let me cast an out param in the method call, so it does this switcheroo for me?  I can't figure out any syntax that'll help, and I can't seem to find anything with google.</p>