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 391053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:01:27+00:00 2026-05-12T16:01:27+00:00

I have a class in vb.net like Public Class Customer Private _Name As String

  • 0

I have a class in vb.net like

Public Class Customer
    Private _Name As String
    Public Overridable Property Name() As String
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            _Name = value
        End Set
    End Property
End Class

and a class deriving from it

Public Class ProxyCustomer
    Inherits Customer
    Private _name As String
    Public Overrides WriteOnly Property Name() As String
        Set(ByVal value As String)
            _name = value
        End Set
    End Property
End Class

which gives me following error
Public Overrides WriteOnly Property Name() As String’ cannot override ‘Public Overridable Property Name() As String’ because they differ by ‘ReadOnly’ or ‘WriteOnly’

but i have same construct in C#

public  class Customer 
{
    public virtual string FirstName { get; set; }     
}

public class CustomerProxy:Customer
{

   public override string FirstName
   {
       set
       {
           base.FirstName = value;
       }
   }

}

which works, so the first thing is , is this consistent because 2 languages are behaving in a very inconsistent way.

secondly, when i do a reflection to get a property, so for example

Dim propInfo  = GetType(Customer).GetProperty("Name")

the propINfo.canRead property is always false, shouldn’t this be true since base class implements the getter of the property ?

many thanks

  • 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-12T16:01:28+00:00Added an answer on May 12, 2026 at 4:01 pm

    I’ll deal with the 2nd part first. In your current vb.net code, the derived Name property replaces the original for the reflection lookup. So that reflection code only see the WriteOnly version of the property. Worse, you completely replace the backing store in your derived setter, so your getter is checking a completely different variable than the one you set.

    As for the first question, when overriding properties in vb.net, you always need to override both the getter and the setter, even if you just replace it with an identical implementation:

    The code should read like this:

    Public Class ProxyCustomer
        Inherits Customer
    
        Public Overrides Property Name() As String
            Get
                Return MyBase.Name ''# Return the original parent property value
            End Get
            Set(ByVal value As String)
                MyBase.Name = value
            End Set
        End Property
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a .NET class like so: public class Person { public string
I have a .net application (c#) that goes something like this public partial class
I got a Utility module since VB.NET doesn't have static class like C# and
I have a fairly standard .Net MVC Controller method: public ActionResult Add(Customer cust) {
If I have the following domain object: public class Customer { public virtual Guid
I have a class level price variable decalred inside a page, like this: public
Say I have a User Control in ASP.NET that contains a button: public class
I have a .NET class library containing a class with a method that performs
I have inherited a class in vb.net and when I create the object, I
I have a class 'Database' that works as a wrapper for ADO.net. For instance,

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.