views:

72

answers:

1

I can easily do this in C#...but I need the equivolent in VB.Net. I need to be able to implement various IAsyncResult properties in VB.Net.

IN C#

Works like a champ...

public object AsyncState { get; set; }

IN VB.NET - THIS FAILS

This fails because you cannot overload a property in VB.Net

Public ReadOnly Property AsyncState() As Object Implements IAsyncResult.AsyncState
    Get
        '... the GET's code goes here ...
    End Get
End Property
Public WriteOnly Property AsyncState() As Object
    Set(ByVal value As Object)
        '... the SET's code goes here ...
    End Set
End Property

IN VB.NET - BOTH THESE FAIL

This fails the "must implement IAsyncResult" requirement

Public AsyncState As Object
Public AsyncState As Object Implements IAsyncResult.AsyncState

Any help is appreciated.

A: 

The VB.NET syntax doesn't permit this as the error message makes clear:

Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers

You'll need to add a method to compensate for the missing property setter:

Public Sub SetAsyncState(ByVal state As Object)
    '' etc...
End Sub
Hans Passant
That's what I thought...just wanted to make sure. Thanks!