Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6036681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:57:38+00:00 2026-05-23T05:57:38+00:00

Is there a way for implementers of an interface where a ReadOnly property is

  • 0

Is there a way for implementers of an interface where a ReadOnly property is defined to make it a complete Read/Write Property ?

Imagine I define an interface to provide a ReadOnly Property (i.e., just a getter for a given value) :

Interface SomeInterface

    'the interface only say that implementers must provide a value for reading
    ReadOnly Property PublicProperty As String

End Interface

This means implementers must commit to providing a value. But I would like a given implementer to also allow setting that value. In my head, this would mean providing the Property‘s setter as part of the implementation, doing something like this :

Public Property PublicProperty As String Implements SomeInterface.PublicProperty
    Get
        Return _myProperty
    End Get
    Set(ByVal value As String)
        _myProperty = value
    End Set
End Property

but this will not compile as, for the VB compiler, the implementer no longer implements the interface (because it is no longer ReadOnly).

Conceptually, this should work, because, in the end, it just means Implement the getter from the Interface, and add a setter method. For “normal methods”, this would be no problem.

Is there some way of doing it, without resorting to “interface hiding” or “home-made” SetProperty() method, and style having the Property behave like a Read/Write property in the implementations ?

Thanks !

–UPDATE–
(I have moved this question to a separate Question)
My question is really : “why can’t this be done in VB.NET”, when the following is valid in C#.NET?” :

interface IPublicProperty
{
    string PublicProperty { get; }
}

with implementation :

public class Implementer:IPublicProperty
    {
        private string _publicProperty;

        public string PublicProperty
        {
            get
            {
                return _publicProperty;
            }
            set
            {
                _publicProperty = value;
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:57:39+00:00Added an answer on May 23, 2026 at 5:57 am

    In the end, I ended up with a solution that matches my goal :

    • users that access via the Interface see at least a getter
    • users that access the implementation can Read and Write.

    I did this “shadowing” the implemented property like this :

    'users who access through interface see only the Read accessor
    Public ReadOnly Property PublicProperty_SomeInterface As String Implements SomeInterface.PublicProperty
        Get
            Return _myProperty
        End Get
    End Property
    
    
    'users who work with the implementation have Read/Write access
    Public Property PublicProperty_SomeInterface As String
        Get
            Return _myProperty
        End Get
        Set(ByVal value As String)
            _myProperty = value
        End Set
    End Property
    

    Then, depending on how you use it, you can do :

    Dim implementorAsInterface As SomeInterface = New InterfaceImplementor()
    logger.Log(implementor.PublicProperty) 'read access is always ok
    implementor.PublicProperty = "toto" 'compile error : readOnly access
    
    Dim implementor As InterfaceImplementor = New InterfaceImplementor()
    implementor.PublicProperty = "toto" 'write access
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way just like multidatatrigger behavior of WPF also implemented in Silverlight
I wish to know is there any way in which I can make it
I have a class that has a property that is defined as interface. Users
Is there a way to continue to utilise auto-implemented properties while still raising a
Is there a simple way to retrieve the length of an associative array (implemented
Is there a simpler way of implement this? Or a implemented method in JDK
Is there any non-hacky way to determine wether a class' superclass implements a particular
Is there way in next piece of code to only get the first record?
is there way thats i can preselect an item when the page loads or
is there way how to get name ov event from Lambda expression like with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.