Congrats! You’ve finished a lot of content and some of the most important concepts in C#. When someone asks you, “How do I make a custom data type in C#?” you can talk all about it! In this lesson, you learned how to:

  • Define a class
  • Instantiate an object using new
  • Define fields, the pieces of data for each class
  • Define properties, the spokespeople for each field
  • Define automatic properties, the shorthand for making properties
  • Define methods, the actions a class can take
  • Define constructors, the special methods called when a class is instantiated
  • Overload constructors and reuse code with this
  • Control access to class members using public and private



Try out your complete Forest class in Main()!

  • Instantiate a new object with the name "Amazon". Store the result in a variable.
  • Print the Trees property to the console.
  • Call the Grow() method.
  • Print the Trees property again to the console to confirm that the Grow() method works.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?