❔ Non-nullable field 'rating' must contain a non-null value when exiting constructor

Why am i getting this warning: Non-nullable field 'rating' must contain a non-null value when exiting constructor?
Before exiting the constructor Rating = aRating is executed and thus rating should be set rating to "G" or "PG" right?

c#
 internal class Book
    {
        private string title;
        private string rating;
        public Book(string aTitle, string aRating)
        {
            title = aTitle;
            Rating = aRating;
        }
        public string Rating
        {
            get { return rating; }
            set { 
                if(value == "G")
                {
                    rating = value;
                }
                else
                {
                    rating = "PG";
                }
            }
        }
    }
image.png
Was this page helpful?