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

The Archive Base Latest Questions

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

Here is the problem, I wanted to define a property which accepts decimal numbers

  • 0

Here is the problem, I wanted to define a property which accepts decimal numbers and do some process on the value and return string such as the below:

Public Property Amount() As String
    Get
        Return Utility.PaddingRight(Me.msAmount.ToString(), 10)
    End Get
    Set(ByVal vsValue As Decimal)
        Me.msAmount = vsValue
    End Set
End Property

But compilers warns “Set parameters must have the same type of the containing property.”

It doesn’t look like it should throws an error since it looks legit.

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

    The reason that you can’t is because what you put into a property should be exactly the same as what you get out of it. If the type changed then this condition would never be true. Microsoft’s spec says that “Properties are like smart fields”. Imagine if a field (class variable) changed between reading and writing.

    Your goal is completely valid but that’s not the intended use for properties. (By “intended goal” I mean Microsoft’s intended goal.) Your design would also opens doors for potential problems if an invalid or null string were passed in. One of the design goals for properties is that they are light weight and shouldn’t throw errors. They can but shouldn’t. The recommended solution is to use the TryParse pattern for your property.

    EDIT

    Sorry, my brain was sidetracked, your goal is changing the getter, not the setter. The pattern that you’re looking for is just a read-only property (as @msarchet pointed out) that’s specific to your getter. For instance, AmountForPrint or something. You should still include a read/write for your actual value, too.

    Public ReadOnly Property AmountForPrint
        Get
            Return Me.Amount.ToString()
        End Get
    End Property
    Public Property Amount As Integer
        Get
    
        End Get
        Set(value As Integer)
    
        End Set
    End Property
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a problem Statement : Define a procedure that takes three numbers as
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I am having some serious problem here. When do we need a class exactly?
I have a problem that's equal to the one presented here: how to define
What is the problem here? (Besides having redundant code). $.getJSON works as expected. However
I have a problem here. My Zend_Forms do not render in view script. Via
I've got a problem here with an MSI deployment that I'm working on (using
Just a small SVN problem here. I setup my own SVN server Setting up
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I'm facing a problem here, with HttpListener. When a request of the form http://user:password@example.com/

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.