C#: Class return value - or is there a better way?
<p>I created a class that had one member of type List. I could then add to this using <code>ClassNameInstance.Add()</code>.</p>

<p>We are now using some code from a third-party that will automatically use any class I create and its values. Except lists. It only returns the first element in the list.  </p>

<p>What I need is a comma-separated version returned instead for this third-parties code to use.  Now I could just append the Strings to a String member, but this doesn't look as nice as the .Add() method.</p>

<p>So I wanted to create my own Class that I could have an Add() method for but could access its single value like so:</p>

<pre><code>MyClass1.Add("Test1");
MyClass1.Add("Test2");

Console.WriteLine(MyClass2);
</code></pre>

<p>The output I would like would be <code>Test1, Test2</code>.  I hope this makes sense!</p>

<p>UPDATE1:</p>

<p>Seems the above may not have been clear.</p>

<pre><code>public class MyClass1
{
    ????
}

public class MyClass2
{
    MyClass1 mc1 { get; set; }
    String name { get; set; }
}
</code></pre>

<p>The third party code will use MyClass2 and its assigned values. When I used List instead of MyClass1 I only get the first value in the list, but need a CSV list as a String returned.</p>

<pre><code>MyClass2 mc2 = new MyClass2();

mc2.mc1.Add("Test1");
mc2.mc1.Add("Test2");

Console.WriteLine(mc2.mc1) should output -&gt; Test1, Test2
</code></pre>

<p>Hope that clears things up some more!</p>

<p>Thanks everyone! :)</p>

<p>UPDATE2:</p>

<p>It seems everyone is suggesting the same thing - use ToString().</p>

<p>Unfortunately, the third-party code will look at my class and determines the members type and value automatically. This means that I am not able to pass the code the value that would be returned by calling ToString().</p>

<p>I kind of need the add/remove functionality of a List&lt;> but when used its value returns as a single CSV string.</p>
