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

Giulio Vannini
Giulio Vannini
21,922 Points

Help with Model Challenge in ASP.Net MVC basics

I cannot get past with what i wrote! Any ideas?

VideoGame.cs
namespace Treehouse.Models
{
    public class VideoGame
    {

        public int Id
        {
              get
             {
                return Id;
             }
        }

        public string Title
        {
              get
             {
                return Title;
             }

            set
            {
                Title = value;
            }


        }

        public string Description
        {
              get
             {
                return Description;
             }
        }

        public string[] Characters
        {
              get
             {
                return Characters;
             }
        }

        public string Publisher
        {
              get
             {
                return Title;
             }
            set
            {
                Title = value;
            }



        }

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


        }


    }

}

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

Take a look at your getter and setter for Publisher. It looks like you copied and pasted the code but forgot to change the property because you are getting and setting Title instead. It works better and is less error prone if you use the getter/setter shorthand instead.

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 +")";
            }
        }
    }
}