Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Joe Mamma,

 

Thanks for the example of how to use a Global Class it has been a really help and I am in the process of getting rid of all the Global Variables :p .

 

I however do need a bit of help of how to write a public property for an arraylist. Below is the code that I am using but it is giving me an error 'Object reference not set to an instance of an object'

 

Public Class ICASData

   Private Shared mInstance As ICASData
   Private mPermissions As ArrayList

   Private Sub New()
   End Sub

   Public Property Permissions() As ArrayList
       Get
           Return mPermissions
       End Get
       Set(ByVal Value As ArrayList)
           mPermissions = Value
       End Set
   End Property

   Shared ReadOnly Property Instance() As ICASData
       Get
           If mInstance Is Nothing Then mInstance = New ICASData()
           Return mInstance
       End Get
   End Property
End Class

 

And this is the code that I am using to try and set the arraylist property.

 

ICASData.Instance.Permissions.Add("RW")

 

But it's not working, any help from you guys would be of great help.

 

Cheers

 

Simon

  • *Experts*
Posted

At a quick glance you might want to replace Private mPermissions As ArrayList with

Private mPermissions As New ArrayList

And

   Public Property Permissions() As ArrayList
       Get
           Return mPermissions
       End Get
       Set(ByVal Value As ArrayList)
           mPermissions.AddRange(Value)
       End Set
   End Property

 

I haven't tested this but I think it should work fine.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...