Variable number of results from a function
<p>I have code similar to the following in many places:</p>

<pre><code>var dbParams = db.ReadParams(memberID, product, GetSubscriptionFields());
Debug.Assert(dbParams.Count == 4);

_memberCode = dbParams[0];
_password = dbParams[1];
_userName = dbParams[2];
_reasonCode = dbParams[3];
</code></pre>

<p>ReadParams() returns an array of strings, the number of strings depending on the GetSubscriptionFields() function. I could use dbParams[] directly in my code, but I find it more helpful to give meaningful names to each of the values in the array. Is there a way I can get all the results directly, without going through the array?</p>

<p>I am looking for something like:</p>

<pre><code>db.ReadParams(memberID, product, out _memberCode, out _password, out _userName, out _reasonCode);
</code></pre>

<p>or</p>

<pre><code>Tuple&lt;_memberCode, _password, _userName, _reasonCode&gt; = db.ReadParams(memberID, product);
</code></pre>

<p>Of course, it has to be legal C# code :)</p>
