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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:34:39+00:00 2026-05-12T21:34:39+00:00

Is there ever a situation where I should do the following in .NET instead

  • 0

Is there ever a situation where I should do the following in .NET instead of using a property with read/write capability?

private S as string

public function GetS() as string
     return S
end function

public sub SetS(byval NewS as string)
    S = NewS
end function

Do properties simply provide a more efficient way for doing the same thing?

Will properties be any slower than the above accessor functions in a high performance application?

  • 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-12T21:34:40+00:00Added an answer on May 12, 2026 at 9:34 pm

    Properties, internally, are nothing but a pair of methods. They basically evaluate to a get and set accessor method.

    You should use properties, unless the property is going to cause some unexpected, potentially long running side effect, or there is some other good reason to use a method.

    For details, I suggest reading the Property Usage Guidelines on MSDN. In particular, use a method when:

    • The operation is a conversion, such as Object.ToString.
    • The operation is expensive enough that you want to communicate to the user that they should consider caching the result.
    • Obtaining a property value using the get accessor would have an observable side effect.
    • Calling the member twice in succession produces different results.
    • The order of execution is important. Note that a type’s properties should be able to be set and retrieved in any order.
    • The member is static but returns a value that can be changed.
    • The member returns an array.

    Otherwise, I’d use a property. Brad Abram’s blogged some other details, including good reasons why certain API functions use methods (mostly because they could cause cross-computer communication, which would fall into the “side effect” category).

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

Sidebar

Related Questions

Is there ever a circumstance where the .MYI files should be bigger than my
We are facing a very weird situation using Visual Studio 2005: There is a
Does -fomit-frame-pointer always omit the frame pointer? Is there ever a situation where both
Is there ever a reason to use Type parameters over generics, ie: // this...
Is there ever reason to think the >> (signed) and >>> (unsigned) right bit-shift
Is there ever a case where a comparison ( equals() ) between two floating
Have you ever obfuscated your code before? Are there ever legitimate reasons to do
What is the difference between type(obj) and obj.__class__ ? Is there ever a possibility
If there was ever a time to hate IE, this is it. This code
Does anyone know if there will ever be a true 64-bit version of Cygwin?

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.