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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:34:02+00:00 2026-05-10T17:34:02+00:00

I have the simple class using auto-implemented properies: Public Class foo { public foo()

  • 0

I have the simple class using auto-implemented properies:

Public Class foo {     public foo() { }        public string BarName {get; set;} } 

I obviously use the variable BarName throughout my class and now need to add logic when the property value is set (it must be all upper case, go figure). Does this mean that I need to now create a private variable for BarName , e.g. _BarName, and change the current BarName variable used throughout my class to _BarName?

Public Class foo {     public foo() {}        private string _BarName = '';     public string BarName      {          get {return _BarName;}         set {_BarName = Value.ToString().ToUpper();}     } } 

I am trying to make sure I understand the implications of using auto-implemented properties, and what it will entail down the road when/if I need to change something. I am assuming that the refactoring, as shown above, is not a breaking change because the property is basically staying the same; it just took a little work inside the class to keep it that way and add the needed logic.

Another example, which may be more meaningful is that I need to call some method when a setter or getter is used; more then changing the value.

This seems a fair trade off the the lines and lines of code to setup properties.

  • 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. 2026-05-10T17:34:02+00:00Added an answer on May 10, 2026 at 5:34 pm

    Does this mean that I need to now create a private variable for BarName

    Yes

    and change the current BarName variable used throughout my class

    Do not change the rest of the code in your class to use the new private variable you create. BarName, as a property, is intended to hide the private variable (among other things), for the purpose of avoiding the sweeping changes you contemplate to the rest of your code.

    I am assuming that the refactoring, as shown above, is not a breaking change because the property is basically staying the same; it just took a little work to keep it that way and add the needed logic.

    Correct.

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer None of the proposed solutions worked as what I needed… May 11, 2026 at 9:44 am
  • added an answer Does it have SetStyle(ControlStyles.UserPaint, True) set? Or, does it have… May 11, 2026 at 9:44 am
  • added an answer Making string a reference type seems entirely reasonable to me.… May 11, 2026 at 9:44 am

Related Questions

I have the simple class using auto-implemented properies: Public Class foo { public foo()
I have a simple GUI component written in Java. The class draws an analog
hi i forgot the code which in a sample class you have to add
I have this sample text, which is retrieved from the class name on an
I have the following simple button with an image as the template. The problem
Let's say I have the following simple enum: enum Response { Yes = 1,
Let's say I have the following simple table variable: declare @databases table ( DatabaseID
I have the following very simple Javascript-compatible regular expression: <script type=text/javascript id=(.+) src=([^]+)> I
I have the following dead simple elisp functions; the first removes the fill breaks
I have the following (fairly) simple JavaScript snippet that I have wired into Greasemonkey.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.