0

Get; Set; I need som good explanaition.

I can not understand what the Get; and Set; actually does, and how you use it.

16th Jun 2016, 4:38 PM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
3 Answers
+ 1
if you have a class with Fields (there just variables but then for classes) you make them private. so only the class it self can acces it. but if you want to give acces from outside. so from outside the class for example an other class the you make a proportie with the same name. Its Like a methode and you then use the get {Return value;} to get the value and the set {example = value;}. in this way you can set logica rules for the set Like: set { if (value > 10){example = value;} else {example = false} } you could even throw an exception if the first if expression is set to false.
17th Jun 2016, 2:43 PM
Xavier Vinken
Xavier Vinken - avatar
- 2
Get: outputs to the console. Set: you have to input a something in the console
19th Jun 2016, 10:42 AM
Francis
Francis - avatar
- 2
Get: outputs to the console. Set: you have to input a something in the console
19th Jun 2016, 10:42 AM
Francis
Francis - avatar