There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
Apologies for the poor formatting. I don’t know how to make my double enters show up.
I am having difficulty understanding how fields and objects relate to each other. I find it helpful when these concepts are related to concepts which I am already familiar with. For example, relating a field to a variable. This is done in the explanation that I took from exercise and typed out below:
"Create fields like this:
class Forest { public string name; public int trees; }
This might look similar to defining a variable. It is! Each field is a variable and it will have a different value for each object."
The problem is that it seems to me that the concept of object was also related to a variable in an example and explanation from the previous exercise.
This example states that ‘phrase’, a variable, is an instance of string. To me the use of the words ‘instance of string’ suggests that phrase is an object of string.
I say this because the definition of object involves the words ‘instance of a class’ and class is contrasted to the custom data types like string.
I hope this makes sense so far. Could someone please explain why I am wrong about ‘phrase’ being an object of string.
Also, if class relates to data types, and fields relate to variables, then what are objects? The values assigned to the variables?
Thank you so much if you took the time to read this.
No, sorry mate. I’ve been super busy the last few weeks and so I’ve put the c# learning on hold. In a few weeks I’ll have more time and I’ll update you if I work it out
If you are having a hard time wrapping your mind around this I would recommend watching Brackeys’ “How to program in C# - Classes (E07)” all the way through then doing the Codecademy afterword. It really helped me.