Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
AnswerRe: Database connectivity in C# using ADO.net Pin
albCode21-Jun-06 1:06
albCode21-Jun-06 1:06 
Questionloading a page in webbrowser ? Pin
cmpeng3421-Jun-06 0:46
cmpeng3421-Jun-06 0:46 
AnswerRe: loading a page in webbrowser ? Pin
Ed.Poore21-Jun-06 1:42
Ed.Poore21-Jun-06 1:42 
QuestionHow to add librariesin C# ( 2005 framework)? Pin
Andy Rama21-Jun-06 0:28
Andy Rama21-Jun-06 0:28 
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 
Yes it is definately good practice. There is a slight mistake in it, it should be

C#
get
{
   return x;
}

And no () parentheses after X.

X is called the property of x and the reason it is good practice is because in the GET and SET section you can write code to perform any operation you want. For example, you might have a boolean variable (call it 'ready') in your class and you would only allow users to retrieve the value of x if 'ready' is true. So you could do the following:

C#
get
{
   if (ready) return x;
   else return 0; // or any value
}

The same thing can be applied to the SET section, where you could for instance only allow writing of a value if 'ready' is true:

C#
set
{
   if (ready) x = value;
   else x=0; // or any value
}

Now, if a variable only has a get property, it's said to be read-only. Obvsiously, since you cannot set its value to anything.

I hope this helps a bit.

Talal

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
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 
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 

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.