Static Members: Static Fields and Properties, error CS1519

Currently stuck on an exercise. I can’t see any obvious difference between my code and Codecademy’s given solution , so I’m confused as to why this doesn’t work.

using System;

namespace StaticMembers
{
  class Forest
  {
    // FIELDS
    
    public int age;
    private string biome;
    private static int forestsCreated;
    
    // CONSTRUCTORS
    
    public Forest(string name, string biome)
    {
      this.Name = name;
      this.Biome = biome;
      Age = 0;
    }
    
    public Forest(string name) : this(name, "Unknown")
    { }
    
    // PROPERTIES
    
    public string Name
    { get; set; }
    
    public int Trees
    { get; set; }
    
    public string Biome
    {
      get { return biome; }
      set
      {
        if (value == "Tropical" ||
            value == "Temperate" ||
            value == "Boreal")
        {
          biome = value;
        }
        else
        {
          biome = "Unknown";
        }
      }
    }
    
    public int Age
    { 
      get { return age; }
      private set { age = value; }
    }
    
    public static int ForestsCreated;
    {
      get { return forestsCreated; }
      private set { forestsCreated = value; }
    }
    
    // METHODS
     
    public int Grow()
    {
      Trees += 30;
      Age += 1;
      return Trees;
    }
    
    public int Burn()
    {
      Trees -= 20;
      Age += 1;
      return Trees;
    }
    
  }

}

If anyone could shed any light on this, I would be grateful.

Hello, @ptraynor894.

Compare the two properties in your code below. :wink:

I see it now, thanks, solved.

2 Likes

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.