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
STAFF
Jennifer Nordell
Treehouse Staff

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
PRO
Jason Wiram
Pro Student 38,629 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
PRO
Jason Wiram
Pro Student 38,629 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
PRO
Carel Du Plessis
Pro 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+")";
       } 

      */
   } 
}