0
Get; Set; I need som good explanaition.
I can not understand what the Get; and Set; actually does, and how you use it.
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.
- 2
Get: outputs to the console. Set: you have to input a something in the console
- 2
Get: outputs to the console. Set: you have to input a something in the console