How to do that without pointers?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brayan__

    #1

    How to do that without pointers?


    Hi all,
    First of all I want to say that I come from C++, where pointers ar
    "kings", but VB.NET don't have pointers :(
    So I try some code like this but it dosn't work:

    Code
    -------------------
    Public Class Class1
    Private objClass2 As Class2

    Public Sub setHash(ByRef hash As Class2)
    Me.objClass2 = hash
    End Sub

    Public Function getValue(ByVal name As String) As String
    Return Me.objClass2.ge tValue(name)
    End Function
    End Class

    Public Class Class2
    Private hastT As Hashtable

    Public Sub New()
    Me.hastT = New Hashtable
    End Sub

    Public Sub addNewValue(ByV al value As String, ByVal name As String)
    Me.hastT.Add(va lue, name)
    End Sub

    Public Function getValue(ByVal name As String) As String
    Return Me.hastT.Item(n ame)
    End Function
    End Clas
    -------------------

    ...

    Code
    -------------------
    Dim objClass11 As New Class1
    Dim objClass12 As New Class1
    Dim objHast As New Class2

    objClass11.setH ash(objHast)
    objClass12.setH ash(objHast)

    objHast.addNewV alue("1", "1")
    objHast.addNewV alue("2", "2")

    Console.WriteLi ne(objClass11.g etValue("1"))
    Console.WriteLi ne(objClass12.g etValue("2")
    -------------------


    Is it posible to set a pointer to an object :confused

    --
    Brayan__Posted from http://www.pcreview.co.uk/ newsgroup acces

Working...