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# ASP.NET MVC Basics Modeling and Presenting Data Creating a Data Model

HELP!!! no answer is working for me

i keep getting the Bummer message

VideoGame.cs
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 + "Super Mario 64 (Nintendo)";  
            }
        }
    }
}

The question was "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)")."

4 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The "Super Mario 64(Nintendo)" is just an example of what it should return. Here's some hints

  • return the Title
  • concatenated with a space and an open parenthesis
  • then concatenate the Publisher
  • then concatenate the closed parentheses

I think you can get it with these hints, but let me know if you're still stuck! :sparkles:

edited for additional hint :bulb: In the example Super Mario 64 is the Title. Nintendo is the Publisher.

Jason Wiram
Jason Wiram
42,762 Points

This question hint/feedback is horribly confusing with its use of quotation marks. It makes it very confusing as to whether the returned string should have quotes around the Publisher, Title, both, etc. Answer: no quotes anywhere.

return Title + " (" + Publisher + ")";
James Churchill
James Churchill
Treehouse Teacher

Jason,

I changed the instructions for task 2 to:

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. For example, given a Title property value of "Super Mario 64" and a Publisher property value of "Nintendo", the property's return value should be: Super Mario 64 (Nintendo)

Do you think that will help reduce confusion?

Thanks ~James

Jason Wiram
Jason Wiram
42,762 Points

James Churchill that should work. It was a minor confusion that made it difficult to grasp the intention. It reads better know. Great C# courses, by the way.

Carel Du Plessis
PLUS
Carel Du Plessis
Courses Plus Student 16,356 Points

can someone explain why my commented out code produce a CS1014 error : https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs1014

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;} 

       // this works?? 
       // why is the get{} needed why can't i just use return
       public string DisplayText{
         get 
     {
           return Title + " " + "("+Publisher+")";
         }
       } 

      /*
    this generates a CS1014 error "A get or set accessor expected" "A method declaration was found in a property declaration. You can only declare get and set methods in a property."

    public string DisplayText{
           return Title + " " + "("+Publisher+")";
       } 

      */
   } 
}