Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
kevinnicol17-Dec-10 8:23
kevinnicol17-Dec-10 8:23 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly17-Dec-10 8:39
Jeff Connelly17-Dec-10 8:39 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
kevinnicol17-Dec-10 8:47
kevinnicol17-Dec-10 8:47 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly17-Dec-10 8:50
Jeff Connelly17-Dec-10 8:50 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Toli Cuturicu17-Dec-10 15:00
Toli Cuturicu17-Dec-10 15:00 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly20-Dec-10 4:21
Jeff Connelly20-Dec-10 4:21 
AnswerRe: What's the purpose to use Property with set and get to change a field? Pin
PIEBALDconsult17-Dec-10 2:28
mvePIEBALDconsult17-Dec-10 2:28 
AnswerRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly17-Dec-10 6:03
Jeff Connelly17-Dec-10 6:03 
nstk wrote:
As I know from OOP theory, the purpose of private Properties is to have the variables of an object protected from other classes, that could accidentaly change their value, thus provoking complications in a software. Am I correct till here?


Only partially. The other reason is to hide the implementation, so that it can change in the future. The calling code only needs to know the property name (or private function name). However you can change how you calculate the value.

So it's for future change, as well as current privacy. That's where the complication of properties comes in handy. Next month, you might rewrite your Category property to look like this

public int Category
{
get {
if (cat < 0) return 0;
else return cat;
}
set { cat = value; }
}
QuestionHow can I start with C/S programming? [modified] Pin
zouleisheng16-Dec-10 19:09
zouleisheng16-Dec-10 19:09 
AnswerRe: How can I start with C/S programming? Pin
Richard MacCutchan16-Dec-10 22:52
mveRichard MacCutchan16-Dec-10 22:52 
GeneralRe: How can I start with C/S programming? Pin
zouleisheng16-Dec-10 23:52
zouleisheng16-Dec-10 23:52 
GeneralRe: How can I start with C/S programming? Pin
Richard MacCutchan17-Dec-10 1:34
mveRichard MacCutchan17-Dec-10 1:34 
AnswerRe: How can I start with C/S programming? Pin
Jeff Connelly17-Dec-10 6:18
Jeff Connelly17-Dec-10 6:18 
GeneralRe: How can I start with C/S programming? Pin
zouleisheng19-Dec-10 5:51
zouleisheng19-Dec-10 5:51 
GeneralRe: How can I start with C/S programming? Pin
Jeff Connelly20-Dec-10 4:26
Jeff Connelly20-Dec-10 4:26 
GeneralRe: How can I start with C/S programming? Pin
zouleisheng21-Dec-10 1:26
zouleisheng21-Dec-10 1:26 
Questionsample digital signage Pin
mukesh.mr0316-Dec-10 18:19
mukesh.mr0316-Dec-10 18:19 
AnswerRe: sample digital signage Pin
Mycroft Holmes16-Dec-10 21:09
professionalMycroft Holmes16-Dec-10 21:09 
GeneralRe: sample digital signage Pin
mukesh.mr0316-Dec-10 22:27
mukesh.mr0316-Dec-10 22:27 
QuestionTrying to create a new array Pin
turbosupramk316-Dec-10 14:46
turbosupramk316-Dec-10 14:46 
AnswerRe: Trying to create a new array Pin
PIEBALDconsult16-Dec-10 15:25
mvePIEBALDconsult16-Dec-10 15:25 
GeneralRe: Trying to create a new array Pin
turbosupramk316-Dec-10 15:28
turbosupramk316-Dec-10 15:28 
GeneralRe: Trying to create a new array Pin
turbosupramk316-Dec-10 15:33
turbosupramk316-Dec-10 15:33 
GeneralRe: Trying to create a new array [modified] Pin
turbosupramk316-Dec-10 15:42
turbosupramk316-Dec-10 15:42 
GeneralRe: Trying to create a new array Pin
PIEBALDconsult16-Dec-10 16:37
mvePIEBALDconsult16-Dec-10 16:37 

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.