C# Complex Return Types
<p>I am new to C# and find myself in situations sometimes where I have to return complex return types for some functions. Like the function may take in some object and return a different view of that object: some fields added, some removed, etc. And other times, I may take in a list of objects and want to return a list of some modified objects and possibly some aggregate calculations on all of them together.</p>

<p>I could accomplish these kinds of things by returning C# native types (like object[]), but it gets ugly to have object[] of object[]'s and then in code have to "know" that object[0][1] corresponds to something. </p>

<p>I suspect it makes sense to create a truly new class called like a FnFooReturn, but then where does it make the most sense to include the definition of such classes so that anywhere that calls the function can use it?</p>

<p>Edit:
A specific example:
I have a function Foo that takes in a list of objects like:</p>

<pre><code>(int id, int num, string name)
</code></pre>

<p>so some example data could be:</p>

<pre><code>(1, 100, "foo")
(1, 203, "foo")
(2, 400, "bar")
(3, 10, "cat")
</code></pre>

<p>and I want to return a list of objects like:</p>

<pre><code>(int id, string name, int[] nums)
</code></pre>

<p>to look like:</p>

<pre><code>[(1, "foo", [100, 103]), (2, "bar", [400]), (3, "cat", [10])]
</code></pre>

<p>so basically it is just a different view of the original list of objects except it combines together all of the objects with the same id to make it easier to loop over in other code later. </p>
