Cinchoo – ChoObject.ToString(), Part 4

Handling Array Members

Cinchoo framework handles Array/List<T> members while constructing string represent of a type.

For a type below having array member

[ChoTypeFormatter("'{this.Name}' Portfolio State")]
public class Portfolio : ChoObject
    public string Name;
    public string Description;
    public string[] Securities;

    public Portfolio(string name, string description, string[] securities)
        Name = name;
        Description = description;
        Securities = securities;
static void Main(string[] args)
        Portfolio portfolio = new Portfolio("High-Growth", "High Growth Portfolio", new string[] { "AAPL", "GOOG", "IBM" });

The output will be

-- 'High-Growth' Portfolio State --
        Name: High-Growth
        Description: High Growth Portfolio
        Securities [Length: 3]:

Press any key to continue . . .

You can override the default behavior by providing your own formatter. I’ll talk about creating one and using it in a type to customize it.

Happy coding!!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s