Question Reference BitArray Instance from all functions within a class

jonsamwell

New member
Joined
Nov 1, 2008
Messages
2
Programming Experience
3-5
Hi,

I have a problem using a private instance variable of type BitArray from my functions. I create an object reference to type BitArray as one of my private class variable. Then in the constructor i fill the BitArray with data.

However, i need to use the information contained in that BitArray when other functions of my class are called

I keep get the error object reference not set to a instance of the object. i.e. i haven't created a new object reference using the keyword.

However, in my class constructor i have. Whenever i try and acces the getInstance() function to return the info in AA(i) i get the above error that i need to create a new instance of the BitArray Class.

How can i put data in the array and use it from all my functions within that class?

See the below code:


VB.NET:
Public Class AA_SecurityEnd 


Sub New(ByVal userID)

        'Set Class Instant Variable
        userID = userID
       
      'put data into array
        Dim k() As Integer = {8, 32, 32, 32, 32}
        Me.AA = New BitArray(k)

End Sub

Public Function getInstance( ByVal i as Integer ) As Boolean
        Return Me.AA( i )
End Function
   
    'Class Instance Variables
Private UserID As Integer
Private AA As BitArray

End Class

Thank you in advance,

Jon
 
Post your code where you use the class and it's function; that's probably where the problem lies.
I'd also look into the new generic collections instead of arrays.
 
Post your code where you use the class and it's function; that's probably where the problem lies.
I'd also look into the new generic collections instead of arrays.

You were right it was the way i was creating the object reference.

what do you mean when you say generic collections? what are theses?

regards

Jon
 
Back
Top