public string Name { get { return name; } set { name = value; } } | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

public string Name { get { return name; } set { name = value; } }

i didnt get what "get" and "set" is. Are they methods or something else?

12th Jul 2020, 8:00 PM
Ali Emir Altın
Ali Emir Altın - avatar
3 Respuestas
+ 2
That's a c# special mechanism for maintaining private field in a faster way inclusive way. It is little confuse with compare to other languages. It just same as setting and getting private filed with public methods. get, set are called accessors, if private int a ; is field then you can set get as property like public int A { set { a= value;} get { return a;} } Now you can access a value as object.A (return a value) Or set by object.A=20. //set a=20 Here object is class object.. Next topics will clearly explain about this and It's feature... Continue reading... Hope it helps..
12th Jul 2020, 8:35 PM
Jayakrishna 🇮🇳
12th Jul 2020, 8:13 PM
Ali Emir Altın
Ali Emir Altın - avatar
+ 1
Which language? Pls tag language.. Is that complete code..? Share the link possibly... They are methods generally which are get the value or set values..
12th Jul 2020, 8:12 PM
Jayakrishna 🇮🇳