newbie question about methods vs properties

  • Thread starter Thread starter Flip
  • Start date Start date
F

Flip

I'm coming from java where everything is supposed to be a method, so please
go easy on a newbie.

I'm learning C#/.NET and am a bit confused as to what makes up a property
and what makes up a method. Does anyone have any ideas on a methodology for
this? Like I say I'm used to java where you have getters/setters for
everything. When I moved from VB to java, the method approach took some
getting used to, but I never really understood it in VB either (I relied on
the intellisense :<).

Any ideas are appreaciated. Thanks.
 
Flip,

You probably will get a number of different opinions on this. For me, a
property is used when you want to expose a piece of information that is
inherent to the object. Methods are used when you want to perform an
operation. Granted, there are situations where you should use a method over
a property (setting the value takes a long time, has big consequences, etc,
etc), but generally, this is the rule of thumb I use.

Hope this helps.
 
Back
Top