+ 1

Get and Set in C#

So I've been learning for a while C#, but I took a break and forgot what get and set are for. I tried looking throught some codes but still can't seem to remember exactly how to use them, anyone willing to give me an example and explain?

19th Dec 2018, 4:29 PM
Ilie Laurentiu
Ilie Laurentiu - avatar
1 Resposta
+ 2
Set and get are a way to generate accessors to private data of a class. It creates two methods with the capitalized name of private date. One to get the value and other to set it. In the set method the name 'value' represents the parameter of setter methods. Check this simple example https://code.sololearn.com/cVLfdjlw36Pb/?ref=app
19th Dec 2018, 6:07 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar