> >> public class myclass
> >> {
> >>     string Field1;
> >>     bool Field2;
> >> }
> >>
> >> However, these are fields, rather than properties.
> >
> > Paul -- what's the difference?  Are these like "private fields" for this
> > class to use?
>
>Well, they are private, but only because I made a mistake:  :-)
>
>public class myclass
>{
>    public string Field1;
>    public bool Field2;
>}
>
>Fields are simpler than properties (get; set), and you have less control.
>For example, a property can be read-only, or throw an exception on an
>invalid value.

I'm pretty sure, if I'm remembering my C++ correctly, that you can directly 
access a field from outside a class as long as you declare it public in 
that language also.

In VFP you can use an _assign method on a class property to implement 
read-only or validation. You can, of course, also make the the property 
"protected" or "hidden" and write get/set methods on the class to govern 
access if you want. VFP's implementation of "hidden" is annoying in certain 
contexts, though.

You will sometimes see in programming literature the assertion that get/set 
methods should be used with every property to ensure that properties are 
used only as intended by the designer. The people who make these assertions 
tend to forget that not every project involves creating classes that will 
be used in contexts not controlled by the designer. In most cases in 
single-developer projects, get/set methods are overkill.

>When databinding you must use properties.

That would seem to be somewhat annoying.

Ken Dibble
www.stic-cil.org


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to