Click here to Skip to main content
16,009,965 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to move and zoom an image? Pin
jinzhecheng23-Apr-05 8:52
jinzhecheng23-Apr-05 8:52 
GeneralRe: How to move and zoom an image? Pin
NortonC21-May-05 12:25
NortonC21-May-05 12:25 
Generalconnected to ms sql server Pin
the pink jedi20-Apr-05 6:56
the pink jedi20-Apr-05 6:56 
GeneralRe: connected to ms sql server Pin
Scott Serl20-Apr-05 7:41
Scott Serl20-Apr-05 7:41 
GeneralRe: connected to ms sql server Pin
the pink jedi20-Apr-05 7:56
the pink jedi20-Apr-05 7:56 
GeneralRe: connected to ms sql server Pin
Luis Alonso Ramos20-Apr-05 17:00
Luis Alonso Ramos20-Apr-05 17:00 
GeneralQuestion about properties Pin
xdavidx20-Apr-05 6:55
xdavidx20-Apr-05 6:55 
GeneralRe: Question about properties Pin
Colin Angus Mackay20-Apr-05 10:53
Colin Angus Mackay20-Apr-05 10:53 
xdavidx wrote:
One of his tips was that you should never have a public variable in a class, that you should ALWAYS use properties. This sorta goes against some things that I've read in other books.

What other books?! I've never seen that advice. Bill Wagner is right - you should use properties. You should declare all member variables as private or protected (some people say that even protected is bad - But I think the jury's still out on that one)

Declaring a member variable as public means that encapsulation is broken and anything outside the object can modify the member variables without notice.

Using a property you can control what happens. Sometimes you don't mind that the member variable is updated from outside as any valid value cannot make the state of the object invalid. In this case the property just passes through the value and assigns it to the member variable. What is the point in that? (you might ask.) Well, if in the future you realise that when that variable changes something else must happen then you have your property already set up and adding some lines of code to the property means that you can do the other work without having to modify vast amounts of code to now use the property instead of a member variable.

Sometimes you might only want other code to have read-only access to the member variable's value, in this case you only implement a getter property so that nothing can set values on the property.

Does this help?


My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More


GeneralRe: Question about properties Pin
Andy Moore20-Apr-05 10:55
Andy Moore20-Apr-05 10:55 
GeneralRe: Question about properties Pin
S. Senthil Kumar20-Apr-05 18:01
S. Senthil Kumar20-Apr-05 18:01 
GeneralRe: Question about properties Pin
James T. Johnson20-Apr-05 19:41
James T. Johnson20-Apr-05 19:41 
GeneralThreading Question Pin
sameerhanda20-Apr-05 5:55
sameerhanda20-Apr-05 5:55 
GeneralRe: Threading Question Pin
Stefan Troschuetz20-Apr-05 6:25
Stefan Troschuetz20-Apr-05 6:25 
GeneralUpdater Application Block, version 2.0 is not able to download the files with extension .config Pin
NarayanVl20-Apr-05 5:37
NarayanVl20-Apr-05 5:37 
Generalthe way to load the application to web server Pin
Member 137005820-Apr-05 5:10
Member 137005820-Apr-05 5:10 
GeneralCalling a function by it's name which has been stored in a string Pin
Gareth_Hastings20-Apr-05 4:37
Gareth_Hastings20-Apr-05 4:37 
GeneralRe: Calling a function by it's name which has been stored in a string Pin
S. Senthil Kumar20-Apr-05 4:52
S. Senthil Kumar20-Apr-05 4:52 
GeneralRe: Calling a function by it's name which has been stored in a string Pin
Gareth_Hastings20-Apr-05 5:06
Gareth_Hastings20-Apr-05 5:06 
GeneralRe: Calling a function by it's name which has been stored in a string Pin
S. Senthil Kumar20-Apr-05 5:54
S. Senthil Kumar20-Apr-05 5:54 
GeneralConstructing Delegate from Object and Method ptr Pin
Tristan Rhodes20-Apr-05 3:55
Tristan Rhodes20-Apr-05 3:55 
GeneralRe: Constructing Delegate from Object and Method ptr Pin
leppie20-Apr-05 4:05
leppie20-Apr-05 4:05 
GeneralRe: Constructing Delegate from Object and Method ptr Pin
Tristan Rhodes20-Apr-05 4:39
Tristan Rhodes20-Apr-05 4:39 
GeneralNever mind - Figured it out Pin
Tristan Rhodes20-Apr-05 4:34
Tristan Rhodes20-Apr-05 4:34 
GeneralRe: Never mind - Figured it out Pin
leppie20-Apr-05 8:51
leppie20-Apr-05 8:51 
GeneralIDREES Pin
idreesbadshah20-Apr-05 3:41
idreesbadshah20-Apr-05 3:41 

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.