Reputation: 522
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
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