Click here to Skip to main content
15,898,134 members
Home / Discussions / C#
   

C#

 
GeneralRe: Property vs Variable? Pin
DaveyM6919-Nov-08 14:53
professionalDaveyM6919-Nov-08 14:53 
GeneralRe: Property vs Variable? Pin
Mycroft Holmes19-Nov-08 15:18
professionalMycroft Holmes19-Nov-08 15:18 
GeneralRe: Property vs Variable? Pin
J4amieC19-Nov-08 22:27
J4amieC19-Nov-08 22:27 
GeneralRe: Property vs Variable? Pin
DaveyM6919-Nov-08 23:19
professionalDaveyM6919-Nov-08 23:19 
GeneralRe: Property vs Variable? Pin
PIEBALDconsult19-Nov-08 14:32
mvePIEBALDconsult19-Nov-08 14:32 
AnswerRe: Property vs Variable? Pin
DaveyM6919-Nov-08 14:13
professionalDaveyM6919-Nov-08 14:13 
GeneralRe: Property vs Variable? Pin
That Asian Guy19-Nov-08 14:14
That Asian Guy19-Nov-08 14:14 
AnswerRe: Property vs Variable? Pin
Mark Churchill19-Nov-08 14:45
Mark Churchill19-Nov-08 14:45 
A property can be an interface member, whereas a variable can't be. This means changing the definition of a class to add/remove a property is a breaking change. Generally speaking if "Number" is part of the publically available API, then you want to expose it as a property.

A variable can be passed by reference (ref/out), a property can't be. A variable has only one access modifier, a property can have a different modifier on get/set.

In terms of overhead, the effort of implementation is quite small if you use automatic properties. int Foo { get;set; }. In terms of performance the simple accessor will usually be inlined by JIT, making the performance identical (except on forms - they inherit MarshalByRef).

Also as a property is effectively a stub of metadata pointing to getter and setter methods, they can benefit from things like declarative security, etc.


QuestionCustom Control Selectable Text Pin
AlcedoSoftware19-Nov-08 13:20
AlcedoSoftware19-Nov-08 13:20 
QuestionI need how with a slide show project and a ball bouncing project Pin
Robert Anders19-Nov-08 12:34
Robert Anders19-Nov-08 12:34 
AnswerRe: I need how with a slide show project and a ball bouncing project Pin
Colin Angus Mackay19-Nov-08 12:48
Colin Angus Mackay19-Nov-08 12:48 
AnswerRe: I need how with a slide show project and a ball bouncing project Pin
DaveyM6919-Nov-08 13:14
professionalDaveyM6919-Nov-08 13:14 
QuestionMSDN Method Implemented? Pin
Gywox19-Nov-08 12:04
Gywox19-Nov-08 12:04 
QuestionSimple loop problems ?? Pin
nlowdon19-Nov-08 11:11
nlowdon19-Nov-08 11:11 
AnswerRe: Simple loop problems ?? Pin
Wendelius19-Nov-08 11:38
mentorWendelius19-Nov-08 11:38 
GeneralRe: Simple loop problems ?? Pin
Samer Aburabie19-Nov-08 11:50
Samer Aburabie19-Nov-08 11:50 
AnswerRe: Simple loop problems ?? Pin
Christian Graus19-Nov-08 11:47
protectorChristian Graus19-Nov-08 11:47 
GeneralRe: Simple loop problems ?? Pin
nlowdon19-Nov-08 12:12
nlowdon19-Nov-08 12:12 
GeneralRe: Simple loop problems ?? Pin
Colin Angus Mackay19-Nov-08 12:26
Colin Angus Mackay19-Nov-08 12:26 
GeneralRe: Simple loop problems ?? Pin
nlowdon19-Nov-08 13:22
nlowdon19-Nov-08 13:22 
AnswerRe: Simple loop problems ?? Pin
mutafa8119-Nov-08 13:55
mutafa8119-Nov-08 13:55 
AnswerRe: Simple loop problems ?? Pin
That Asian Guy19-Nov-08 14:30
That Asian Guy19-Nov-08 14:30 
AnswerRe: Simple loop problems ?? Pin
JamesChen719-Nov-08 15:18
JamesChen719-Nov-08 15:18 
QuestionData Importing one column Pin
postonoh19-Nov-08 10:29
postonoh19-Nov-08 10:29 
AnswerRe: Data Importing one column Pin
Wendelius19-Nov-08 11:09
mentorWendelius19-Nov-08 11:09 

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.