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 trialPurvi Agrawal
7,960 PointsUnable to Solve this Challenge !
Confused. Not clear what the question asks for !
using System;
namespace Treehouse.CodeChallenges
{
public class VocabularyWord
{
public string Word { get; private set; }
public VocabularyWord(string word)
{
Word = word;
}
public override string ToString()
{
return Word;
}
public override bool Equals(string q){
if(this.Word == q)
return true;
else return false;
}
}
}
1 Answer
James Churchill
Treehouse TeacherPurvi,
You're close to having the correct answer! Let's double check the signature for the method that you're trying to override, Object.Equals
.
https://msdn.microsoft.com/en-us/library/bsc2ak47(v=vs.100).aspx
public virtual bool Equals(Object obj)
And here's your method.
public override bool Equals(string q)
Notice the difference in the parameter types? Try changing your method signature and see where that leads you to next.
Thanks, James
Purvi Agrawal
7,960 PointsJames Churchill Thanks James. Your response helped me to solve the challenge finally :)
James Churchill
Treehouse TeacherPurvi,
Glad to hear it! And great job sticking with it until you found a solution :)
Thanks ~James
William Schultz
2,926 PointsWilliam Schultz
2,926 PointsI think the challenge is bugged. I'm at a loss. If you override the Equals method then it says there is no suitable method to override, but if you don't override it, it says there are multiple methods named Equals. Seems like a lose/lose situation to me. I even tried different signatures for the method.