parameterized read-write property

Posted on 2005-04-25
Last Modified: 2010-04-23
I have to create a read-write property named CarrierName. This property has to accept one argument the aircraftID. Read or write theCarrierName property for the correct AircraftID. Could you please tell me if this is correct.

Public property CarrierName (ByVal AircraftID as Integer) as String
            Return CarrierName(AircraftID)
       End Get
       Set (ByVal value as string)
              CarrierName(AircraftID) = value
       End Set
End Property

I'm in a class and having problems so I can use all the help I can get.

Question by:augie0216
    1 Comment
    LVL 96

    Accepted Solution

    No, that would create a circular reference.  You need an internal field property to store Property Values:

    Private _carrierNames As New HashTable

    Public Property CarrierName (ByVal AircraftID as Integer) As String
                If _carrierNames.ContainsKey(AircraftID) Then
                   Return _carrierNames(AircraftID)
                End If
           End Get
           Set (ByVal Value As String)
                  _carrierNames.Add(AircraftID, Value)
           End Set
    End Property


    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

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    734 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

    18 Experts available now in Live!

    Get 1:1 Help Now