How does the value assignment operator work in this case?
c#, oop
Solution
In the above example we are assigning private read-only Database database the value which gets passed into the AllItems class, is that correct?
Yes
Would it matter if I swapped `this.database = database` around, so it looked like `database = this.database` instead?
Yes, it would. What you would end up doing there is assigning the database parameter being passed in to be the value of the database field (which would be `null` by default).
Where we are saying `this.database`, does this refer to the database in AllItems(Database database) or does it refer to private read-only Database database?
`this` is shorthand for the current class instance, therefore it refers to the private read-only member of database.
Problem
It helps to note I'm very new to c#. But consider the following class: ``` class AllItems { private readonly Database database; public AllItems(Database database) { this.database = database; } } ``` I have the following questions: In the above example we are assigning `private readonly Database database`the value which gets passed into `AllItems` class, is that correct? Would it matter if I swapped `this.database = database` around, so it looked like `database = this.database` instead? Where we are saying `this.database`, does `this` refer to the database in `AllItems(Database database)` or does it refer to `private readonly Database database` ?