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

  • Home
  • SEARCH
  • 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 6021367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:42:09+00:00 2026-05-23T03:42:09+00:00

(this is related to this other question ) If you define an Interface where

  • 0

(this is related to this other question)

If you define an Interface where there is a Property with only a getter (= ReadOnly in VB.NET), why can you define the setter in implementing classes with C# but not with VB ?

I would have thought it was defined at .NET level, and not language-specific.

Example: for this interface

'VB.NET
Interface SomeInterface

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

End Interface

or

//C# code
interface IPublicProperty
{
    string PublicProperty { get; }
}

This is a correct implementation in C# :

public class Implementer:IPublicProperty
    {
        private string _publicProperty;

        public string PublicProperty
        {
            get
            {
                return _publicProperty;
            }
            set
            {
                _publicProperty = value;
            }
        }
    }

But this is invalid in VB.NET

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

UPDATE 2015/04/23

Turns out this feature is coming as part of VB14 !
See Languages features in C# 6 and VB 14 and New Language Features in Visual Basic 14 :

ReadOnly interface properties can be implemented by ReadWrite props
This cleans up a quirky corner of the language. Look at this example:

Interface I
    ReadOnly Property P As Integer
End Interface


Class C : Implements I
    Public Property P As Integer Implements I.P
End Class

Previously, if you were implementing the ReadOnly property I.P, then
you had to implement it with a ReadOnly property as well. Now that
restriction has been relaxed: you can implement it with a read/write
property if you want. This example happens to implement it with a
read/write autoprop, but you can also use a property with getter and
setter.

  • 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-23T03:42:10+00:00Added an answer on May 23, 2026 at 3:42 am

    Be careful assuming that VB.NET and C# are the same language spoken with a different accent – they’re not.

    Because VB.NET requires implementation of an interface member to have that Implements clause, saying which member it is implementing. C# lets you implement interface members explicitly (SORT OF like VB.NET), or implicitly (no VB.NET equivalent). Therefore the actual C# version of this is

    public class Implementer : IPublicProperty
    {
        private string _publicProperty;
    
        string IPublicProperty.PublicProperty    // explicit implementation
        {
            get
            {
                return _publicProperty;
            }
            set
            {
                _publicProperty = value;
            }
        }
    }
    

    and this does gives an error:

    error CS0550: ‘ConsoleApplication171.Implementer.ConsoleApplication171.IPublicProperty.PublicProperty.set’ adds an accessor not found in interface member ‘ConsoleApplication171.IPublicProperty.PublicProperty’

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related to this other question I recently asked... cf.net exception and
This is related to a question I asked the other day on how to
I just can't remember the terminology used for this and other related properties. EDIT
This related to my other question . I have this table CREATE OR REPLACE
This question is related to this other question: Change rails text_field form builder type
This is related to some other questions, such as: this , and some of
The answers to this related question of mine lead me to choose Java for
This is related to the this question and the answer maybe the same but
This is related to this question . I'm writing a Flex app (a WindowedApplication)
This is related to the accepted answer for What’s your #1 way to be

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.