How can I make an interface property read-only in VB.NET?

This is a continuation of the previous question about interfaces. I got an answer that I like, but I'm not sure how to implement it in VB.NET.

Previous question:

Should this property be part of the interface of my object?

public interface Foo{
  bool MyMinimallyReadOnlyPropertyThatCanAlsoBeReadWrite {get;}
}

How can I achieve this using VB.NET syntax? As far as I know, my only option is to mark the property as ReadOnly (I cannot implement the setter) or not (I have to implement the installer).

+2
source share
2 answers

, , . , . , , , , , .

+2

VB.NET :

Public Interface ICanBeSecure

    ReadOnly Property IsSecureConnection() As Boolean
End Interface

Public Interface IIsSecureable
    Inherits ICanBeSecure

    Shadows Property IsSecureConnection() As Boolean
End Interface
+1

Source: https://habr.com/ru/post/1716049/


All Articles