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!
So I just finished an entire lesson explaining references, yet I still don’t understand what is the point of using them?
Lets say I have a Superclass Animal and a subclass Cat.
I create an instance of cat.
Then I create a reference to cat using the Superclass Animal.
The second reference to the object will have only the functionalities defined for the Baseclass (a method defined for the baseclass, for en example), whilst the first reference (cat) will have access to that which was inherited from the superclass and the functionalities exclusive to the derived class.
Guess the point is: in real world scenarios, you might have references that you want only to use what is applicable to the baseclass, while maintaining some functions exclusive to the derived one.
Classes and interfaces are reference types . A variable of this type holds a reference to the data, not the data itself. This is different from value types like int and bool
The equality operator ( == ) uses a referential comparison for reference types and a value comparison for value types
What are all the value types? What are all the reference types?
Referencing has to do with the physical address of data in memory.
One analogy uses lockers: you put items in lockers and then keep track of the data by locker number. The locker number is intrinsically independent from the item it holds.
So to check equality of reference is to ask if two locations are the same, and in contrast value comparison asks if two values (items) are the same.
Arrays for example are stored in consecutive addresses, which gives them specific types of advantages (but some disadvantages). Other data structures will work with data that is placed in separate memory locations but offer other types of efficiencies.
I have some questions:
Can variables be value types and reference types.
I know that all classes are reference types. Do value types not hold a reference but the variable related to it stores the value?
.
In Program.cs, there are two lines that are commented out:
f.Define();
bdiss3.Define();
Before you move on, make sure you can explain why each of them cause an error.
Yeah I don’t actually know. This module has been a little confusing. I’m not sure if it’s me, but I would have found being able to reference the IFlippable and Book code throughout a help but they disappeared after the first lesson. I guess the answer is something like “you’re trying to do something that doesn’t exist in Book or IFlippable” but I have no idea.