473,383 Members | 1,788 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Re: Using readonly properties in a class...

Like this:

Private _FieldValue As <some type>

Public Property Something As <some type>
Get
Return _FieldValue
End Get
Private Set
_FieldValue = value
End Set
End Property

Tom Dacon
Dacon Software Consulting

"Brad Pears" <br***@truenorthloghomes.comwrote in message
news:Oa**************@TK2MSFTNGP03.phx.gbl...
>I have a class that has readonly properties in it. I am fairly new to OO
design and development so please let me know if this doe snot make sense...

The reasopn why I have these read only porperties is becasue these
particular properties are not set programatically - they are as a result
of a calualtion of two other properties as shown below...

public readonly property PSFLiveFactored() as decimal
Get
return PSFLiveFactored = PSFLive * 1.5
end get
end property

I have one readonly property that is derived from an SQL Stored procedure
(called when the object is instantiated) which selects a row from a view.
This particular view includes some calculated rows - one of which I want a
few of my read only properties to contain - as opposed to the way I am
setting them above. Since I cannot (and do not want anyone to) set this
property in code (hence a readonly property), how do I actaully set an
initial value for a read only property?

Would I have to call a private method in the "Get" area that would then
retrieve the data from the DB and use that returned value to set the
property?
Thanks, Brad
Thanks, Brad

Jun 27 '08 #1
0 1269

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
5
by: fred | last post by:
With a Class is there any difference between a readonly property and function besides having to use Get/End Get. Are there any performance/resource advantages for either. Thanks Fred
16
by: Dennis | last post by:
I have a class named "myclass" and an arraylist containing elements of type "MyClass". I want to get the value of a property of "MyClass" (a string type) for one of the arraylist elements. I...
1
by: Jumping Matt Flash | last post by:
I'm trying to achieve a property within a class which returns a conditional result dependent on the class members values. I will explain.. Public Class Address Private addrCountry As String...
5
by: Rob Meade | last post by:
Hi all, Ok - I guess this one will eventually still end up as a "personal choice" kinda answer, but I thought I'd run it passed the wealth of knowledge and experience that's in this group. ...
11
by: dgk | last post by:
If I have a class with a public variable, isn't this the same as a private variable with a property? ie, isn't this: Public Class MyTest Public MyVar as String End Class the same as this: ...
8
by: Scott M. | last post by:
I've tried following the simple instructions to be able to use MyServices within C#...Add a project reference to Microsoft.VisualBasic.dll and add: "using Microsoft.VisualBasic.MyServices;" to the...
1
by: Brad Pears | last post by:
Perfect. That makes more sense then calling a method to run the Stored Proc and return the value in the read only properties "Get" method because then it would be running that everytime someone...
0
by: Simon Woods | last post by:
Hi I was struggling to find a suitable place to ask this question, so if it is not appropriate here and someone can suggest somewhere else please do. My question is concerning IOC containers...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.