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 trialNeale Potgieter
3,715 PointsUnable to return a property in parentheses
I have the following question: "In VideoGame.cs add a read only property named DisplayText of type string. For the property's return value, return the Title property value followed by the Publisher property value in parentheses (i.e. "Super Mario 64 (Nintendo)").". I have tried to place the 'Publisher' return value in parentheses using the " '" + Publisher + "'" but the code is not accepted. Please assist.
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 Title + '"' + Publisher + '"';
}
}
}
}
2 Answers
Steven Parker
231,248 PointsIt looks like you're using the wrong characters.
You're code is adding quotes ("
) around the Publisher, but it should be parentheses ().
And you should use quotes instead of apostrophes ("single quotes") to make your additions strings instead of single characters. That will make it easy to include a space along with the open parenthesis (" ("
) to satisfy the challenge's format expectations.
marcolamoon
16,915 Pointsi am not passing the question. please help!!
Jeanette Brown
20,485 PointsI just figured it out. I had a stray curly brace in mine.
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 Title + " (" + Publisher + ")";
}
}
}
}
Neale Potgieter
3,715 PointsNeale Potgieter
3,715 PointsThanks for the answer but it didn't work. I did the following based on your answer and what the question is asking for:
return Title + (Publisher);
This still returns the same error. I cannot get passed this - it seems simple enough.
Neale Potgieter
3,715 PointsNeale Potgieter
3,715 PointsOk... stupid problem resolved. PEBCAC error :)
Thanks for the help.