Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Intermediate C# System.Object Object.ToString

Trying to add "ToString" method to VocabularyWords.cs

Challenge Task 1 of 1

Add a ToString method to the VocabularyWord class that returns the word.

To me time to figure that I did not have to remove or change the code, just needed to add "ToString method" similar to what was shown in video. Went to msdn.microsoft.com and nothing I could quite understand from those examples shown, so went back to video and rewatch it again.... That when the light bulb went off. :).

VocabularyWord.cs
using System;
namespace Treehouse.CodeChallenges
{
    class VocabularyWord
    {
        public string Word { get; private set; }

        public VocabularyWord(string word)
        {
            Word = word;
        }
    }
}

This was my fix as I did several ways, but got small errors to big ones... So then I just figure not to delete or rewrite what was already in the code, but simply add more, as the video shows. Always fall back to video :).

VocabularyWord.cs
using System;
namespace Treehouse.CodeChallenges
{
    class VocabularyWord
    {
        public string Word { get; private set; }

        public VocabularyWord(string word)
        {
            Word = word;
        }
        public override string ToString()
        {
            return Word;
        }
    }
}