Solved

Help with properties

Posted on 2006-07-11
4
189 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 69

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 69

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now