Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
AnswerRe: Property vs Public Variable Pin
Pete O'Hanlon17-Feb-09 3:48
mvePete O'Hanlon17-Feb-09 3:48 
AnswerRe: Property vs Public Variable Pin
DaveyM6917-Feb-09 4:08
professionalDaveyM6917-Feb-09 4:08 
GeneralRe: Property vs Public Variable Pin
PIEBALDconsult17-Feb-09 5:31
mvePIEBALDconsult17-Feb-09 5:31 
AnswerProperties SUCK! Pin
Ennis Ray Lynch, Jr.17-Feb-09 4:44
Ennis Ray Lynch, Jr.17-Feb-09 4:44 
AnswerRe: Property vs Public Variable Pin
Xmen Real 17-Feb-09 5:17
professional Xmen Real 17-Feb-09 5:17 
AnswerRe: Property vs Public Variable Pin
cmk17-Feb-09 5:25
cmk17-Feb-09 5:25 
AnswerRe: Property vs Public Variable Pin
PIEBALDconsult17-Feb-09 5:42
mvePIEBALDconsult17-Feb-09 5:42 
AnswerRe: Property vs Public Variable Pin
_Maxxx_17-Feb-09 16:51
professional_Maxxx_17-Feb-09 16:51 
I'm not 100% sure about .Net - but I do't think using a 'simple' property uses more processing than using a public variable.

However, a property is more future-prof. if you decide to make a change, and incorporate logic into your getter or setter - it's easer if you already have a getter and setter than if you have a public field. If you're using reflection, you would have to change code to change from a field to a property - and if you mix properties and fields, it can be confusing (as its not obvious which youare using, and using reflection, say to loop over the properties, will miss the fields.

I never use public fields.

The reason being, I see no real advantage of a public field over a simple public property (other than it is less typing - but I don't count that as maintenance is far more expensive than typing time), but sometimes there is advantage to using a property over a public field. Therefore, my standard is to use a property rather than a public field - always. Therefore my fields are always private (or protected) and I know that any access to them is either within that class or a derivative,or via the property.

___________________________________________
.\\axxx
(That's an 'M')

Question.net error in application Pin
ToddHileHoffer17-Feb-09 3:04
ToddHileHoffer17-Feb-09 3:04 
QuestionAccessing Website Content Pin
Rahul Babu17-Feb-09 2:21
Rahul Babu17-Feb-09 2:21 
AnswerRe: Accessing Website Content Pin
SeMartens17-Feb-09 2:23
SeMartens17-Feb-09 2:23 
AnswerRe: Accessing Website Content Pin
dan!sh 17-Feb-09 2:30
professional dan!sh 17-Feb-09 2:30 
AnswerRe: Accessing Website Content Pin
N a v a n e e t h17-Feb-09 2:36
N a v a n e e t h17-Feb-09 2:36 
GeneralRe: Accessing Website Content Pin
Rahul Babu17-Feb-09 2:45
Rahul Babu17-Feb-09 2:45 
GeneralRe: Accessing Website Content Pin
SeMartens17-Feb-09 2:48
SeMartens17-Feb-09 2:48 
GeneralRe: Accessing Website Content Pin
J4amieC17-Feb-09 3:03
J4amieC17-Feb-09 3:03 
AnswerRe: Accessing Website Content Pin
Eddy Vluggen17-Feb-09 3:26
professionalEddy Vluggen17-Feb-09 3:26 
QuestionProcessStartInfo Pin
Peter Walburn17-Feb-09 1:40
Peter Walburn17-Feb-09 1:40 
AnswerRe: ProcessStartInfo Pin
benjymous17-Feb-09 1:46
benjymous17-Feb-09 1:46 
GeneralRe: ProcessStartInfo Pin
Peter Walburn17-Feb-09 3:06
Peter Walburn17-Feb-09 3:06 
AnswerRe: ProcessStartInfo Pin
SeMartens17-Feb-09 1:49
SeMartens17-Feb-09 1:49 
GeneralRe: ProcessStartInfo Pin
Peter Walburn17-Feb-09 3:07
Peter Walburn17-Feb-09 3:07 
QuestionInstaller Problem Pin
Waheed Ur Rehman17-Feb-09 1:40
Waheed Ur Rehman17-Feb-09 1:40 
AnswerRe: Installer Problem Pin
Xmen Real 17-Feb-09 2:59
professional Xmen Real 17-Feb-09 2:59 
QuestionRead a No of Characters in a Image Pin
devacaleb17-Feb-09 1:19
devacaleb17-Feb-09 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.