HexaGridBrain
HexaGridBrain

Reputation: 522

VB.NET Interface Property with Getter but no Setter

I wonder how I could do an Interface with Read only property in VB.NET?

In C# I'd do something like:

interface ISomething {
    int PropNeeded { get; }
}

But when I try to do the same in VB

Interface ISomething
    Property PropNeeded() As Integer
        Get
        End Get
    End Property 
End Interface 

I got this error message from Visual Studio 2010: "Statement cannot appear within an interface body. End of interface assumed."

Which seems logic, since it's like I tried to give an implementation to the Property... But it's important that the Property has no Setter only a Getter.

Your help would be greatly appreciated!

Upvotes: 0

Views: 1103

Answers (2)

Tilak
Tilak

Reputation: 30728

Interface ISomething
      ReadOnly Property PropNeeded() As Integer
End Interface

As a side note, you can use C# to VB online code converters. Telerik code converter

Upvotes: 2

GSerg
GSerg

Reputation: 78210

Readonly Property PropNeeded() As Integer

Upvotes: 2

Related Questions