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 trialALBERT QERIMI
49,872 Pointsoutput value in parentheses in C#
stuck in this challange anybody help how to output parentheses in C#
Bummer! For the property's return value, are you returning the 'Title' property value followed by the 'Publisher' property value in parentheses (i.e. "Super Mario 64 (Nintendo)")?
namespace Treehouse.Models
{
public class VideoGame{
public int Id {get ; set ;}
public string Title {get ; set;}
public string Description {get ; set; }
public string []Characters {get ; set;}
public string Publisher {get ; set;}
public string DisplayText {
get{
return ////stuck here
}
}
}
}
4 Answers
Justin Horner
Treehouse Guest TeacherHello Albert,
To return a concatenated string you'll need to do something like this.
public string DisplayText
{
get
{
return PropertyA + " (" + PropertyB + ")";
}
}
I hope this helps.
Steven Parker
231,248 PointsYou're so close! You only need to combine the strings along with some parentheses (and a space). There's a few ways to do that. The most basic way would be with string concatenation:
return Title + " (" + Publisher + ")";
On the other end of the scale would be a single-line expression-bodied computed property with string interpolation:
public string DisplayText => $"{Title} ({Publisher})";
Either will pass the challenge, but the latter is probably a bit beyond the scope of the course.
ALBERT QERIMI
49,872 PointsThanks you Guys for help
Anne Yeiser
19,291 PointsThe problem on this challenge is that in the question, the line breaks so that one cannot tell if there is a space after the Title or not. So, not adding the space-- " (" -- does not pass the test.