tags:

views:

224

answers:

2

I just stumbled over this in some C# code...:

public Foo     Foo    { get; private set; }

How can I do the same thing in vb?

+4  A: 

Of course (smacks forehead)...:

Public Property Foo() As Foo
    Get
        ...
    End Get
    Private Set(ByVal value As Foo)
        ...
    End Set
End Property

I did not think about putting the private keyword down there...

Kjensen
+2  A: 

VB.NET does not have automatic properties like C# 3.0 does. In VB the equivalent would be:


    Private _Foo As SomeType
    Public Property Foo() As SomeType
        Get
            Return _Foo
        End Get
        Private Set(ByVal value As SomeType)
            _Foo = value
        End Set
    End Property
emaster70