Click here to Skip to main content
15,914,165 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to add librariesin C# ( 2005 framework)? Pin
gnjunge21-Jun-06 2:46
gnjunge21-Jun-06 2:46 
Questionprinting reporting services Pin
toink toink21-Jun-06 0:19
toink toink21-Jun-06 0:19 
QuestionWhy is this good practice [modified] Pin
S020035621-Jun-06 0:15
S020035621-Jun-06 0:15 
AnswerRe: Why is this good practice Pin
Talal Sultan21-Jun-06 0:30
Talal Sultan21-Jun-06 0:30 
GeneralRe: Why is this good practice Pin
S020035621-Jun-06 0:52
S020035621-Jun-06 0:52 
GeneralRe: Why is this good practice Pin
Talal Sultan21-Jun-06 1:02
Talal Sultan21-Jun-06 1:02 
AnswerRe: Why is this good practice Pin
Divyang Mithaiwala21-Jun-06 1:14
Divyang Mithaiwala21-Jun-06 1:14 
AnswerRe: Why is this good practice Pin
BoneSoft21-Jun-06 4:08
BoneSoft21-Jun-06 4:08 
There are already good answers to your question, but I'll give you the simple answer...

One of the corner stones of object oriented programming is encapsulation. Which means hiding implementation details from the user. When you expose a field you are allowing the user to set that field to anything they wish. When you encapsulate that field with a property, you allow the class the ability to validate data that the user tries to set to that property/field.

When designing a class, it's important to state in some fashion what the expected behaviour of the class is within a finite range of inputs. It's up to the class to determine what valid inputs are so that it can guarantee valid behaviour. Properties allow the class to take input from the user of the class and verify that it can guarantee correct behaviour with the data provided.

Granted, most people just use the most basic functionality for a property, which is to just return or set the field. But when clients of the class are using the property, you can easily change the property to do data checking later without changing how the clients use the class.

Hope that helps.

Visit BoneSoft.com
QuestionMobile application Pin
acodman21-Jun-06 0:15
acodman21-Jun-06 0:15 
AnswerRe: Mobile application Pin
Not Active21-Jun-06 2:52
mentorNot Active21-Jun-06 2:52 
QuestionRunning MSI file from inside a windows forms application Pin
Talal Sultan21-Jun-06 0:07
Talal Sultan21-Jun-06 0:07 
AnswerRe: Running MSI file from inside a windows forms application Pin
Ed.Poore21-Jun-06 1:43
Ed.Poore21-Jun-06 1:43 
GeneralRe: Running MSI file from inside a windows forms application Pin
Talal Sultan21-Jun-06 2:54
Talal Sultan21-Jun-06 2:54 
GeneralRe: Running MSI file from inside a windows forms application Pin
Ed.Poore21-Jun-06 6:04
Ed.Poore21-Jun-06 6:04 
Questioncustom control Pin
GDavy21-Jun-06 0:05
GDavy21-Jun-06 0:05 
AnswerRe: custom control Pin
Talal Sultan21-Jun-06 0:18
Talal Sultan21-Jun-06 0:18 
Questionmaking xml comments mandatory Pin
KrunalC20-Jun-06 23:51
KrunalC20-Jun-06 23:51 
AnswerRe: making xml comments mandatory Pin
Kevin McFarlane21-Jun-06 0:32
Kevin McFarlane21-Jun-06 0:32 
AnswerRe: making xml comments mandatory Pin
Not Active21-Jun-06 2:30
mentorNot Active21-Jun-06 2:30 
AnswerRe: making xml comments mandatory [modified] Pin
BoneSoft21-Jun-06 4:12
BoneSoft21-Jun-06 4:12 
AnswerRe: making xml comments mandatory Pin
Dustin Metzgar21-Jun-06 4:43
Dustin Metzgar21-Jun-06 4:43 
GeneralRe: making xml comments mandatory Pin
KrunalC21-Jun-06 23:20
KrunalC21-Jun-06 23:20 
QuestionCrsytal Report in C# Pin
Alamzeb khan20-Jun-06 22:45
Alamzeb khan20-Jun-06 22:45 
AnswerRe: Crsytal Report in C# Pin
V.21-Jun-06 0:11
professionalV.21-Jun-06 0:11 
QuestionGenerics - Cast value to generic type Pin
Vince Smith20-Jun-06 22:44
Vince Smith20-Jun-06 22:44 

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.