Solved

Help with properties

Posted on 2006-07-11
4
194 Views
Last Modified: 2010-04-23
What case(s) would I need to use
ReadOnly or WriteOnly
properties?

I may have a follow-up or two on this, so I'll start it low and increase it if I need further explanation(s0>
Thanx!
0
Comment
Question by:sirbounty
  • 2
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 125 total points
ID: 17086794
Hi sirbounty,

A often use ReadOnly properties for values that are read from the database and which the application cannot change. For example a tax rate.

Another example where a ReadOnly property is useful is for calculated values. Say for example you have a FirstName and a LastName property, you could create a ReadOnly FullName property which would be FirstName + " " + LastName.

I never use WriteOnly properties. About the only place where I can it could make sens (and even there I am not 100% convinced) is for properties like password. You need a way to set the value but you cannot read from it.

Cheers!
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17086810
a ReadOnly property is useful is for calculated values

This may be what I need then...

Say I have
Person.Age
along with today's date.

If wanted to have
Person.BirthDate

could that be a ReadOnly property?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17086815
sirbounty,

Yes but you should probably better have the BirthDate field in your database (read/write property) and a ReadOnly Age property.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17086838
Yeah - just the quickest example I could come up off the top of my head... ;^)

Thanx, as always.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question