What is the point of an auto implemented property? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What is the point of an auto implemented property?

if you don't need the custom behavior control..simply declare a public variable. No?

26th Jun 2016, 6:51 PM
J Arrow
11 Answers
+ 4
Its never correct to have public variables cuz it is much easier to Edit logic through property
27th Jul 2016, 9:39 AM
Jan Pro
Jan Pro - avatar
+ 3
i think like you.
1st Jul 2016, 4:13 PM
Ronaldo Marques
Ronaldo Marques - avatar
+ 2
if no custom behavior needed, yes you can... but later maybe you want to upgrade/expand your code. then you will see a benefits of auto implemented properties...
20th Nov 2016, 5:55 PM
Nenad Puhalo
Nenad Puhalo - avatar
+ 2
An auto-implemented property can be made read-only, whereas a public data member is always read-write.
1st Jan 2017, 8:29 AM
Igor B
Igor B - avatar
+ 1
@Ronaldo Marques ME TOO, I HAVEN'T FOUND THE ANSWER
5th Jul 2016, 12:23 AM
LUIS DAVID BETANCES MOSQUEA
LUIS DAVID BETANCES MOSQUEA - avatar
+ 1
auto implemented property makes the code faster to write. thinking of it as an option to use when you want a quick way to make a private variable with getters and setters.
14th Nov 2016, 6:11 PM
trevor villanueva
trevor villanueva - avatar
0
I believe you are correct in that if you dont need the custom behavior then just declaring the variable as public is correct (and simpler imo)
22nd Jul 2016, 2:48 PM
EddieBro
EddieBro - avatar
0
I've noticed that high level languages are redundant in so many ways, but I trust in language developers know what they are doing. I have no idea right now why I should use this redundant way of accessing fields but I surely will.
24th Nov 2016, 3:53 PM
Omar Luna
Omar Luna - avatar
0
15th Dec 2016, 5:29 PM
Vidhi Tiwari
Vidhi Tiwari - avatar
0
to implement encapsulation automatically
18th Dec 2016, 2:50 PM
Erik Winar
Erik Winar - avatar
0
i think like you.
19th Dec 2016, 1:55 AM
Carlos Henrique Ribeiro
Carlos Henrique Ribeiro - avatar